Case format for getting cell value from a worksheet.

  • Thread starter Thread starter George
  • Start date Start date
G

George

Good Afternoon,

I need to create a series of Case conditions based on the value of a cell on
a certain worksheet in my open workbook..For the life of me I cannot get the
syntax right and I'd appreciate any help i could get.

My condition is on a worksheet named "Lookup_Values" Cell "M3" is a value
used as a case condition. what I want to do is retrive that value and use it
to compare against each case like below.

RPT_Date = ("Lookup_Values!M3")

Select Case True
Case RPT_Date = "January"
Perform my actrions
Exit Sub

Case RPT_Date = "Febuary"
Perform my actrions
Exit Sub
End Select

I appreciate any help in showing me the error of my ways, and again Thank
You in advance.

George
 
Hi,

Try it this way bit be aware of some pitfalls. The 'test' is case sensitive.
I'm assuming you have the text value of January in M3, if it's a properly
formatted date then this won't work.

To avoid the case issue you could use
Select Case ucase(RPT_Date)

and in the case statements us JANUARY etc

RPT_Date = Sheets("Lookup_Values").Range("M3")
Select Case RPT_Date
Case Is = "January"
' Perform my actrions
Exit Sub
Case Is = "Febuary"
'Perform my actrions
Exit Sub
End Select
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
Select Case RPT_Date
Case "January"
Perform my actrions
Exit Sub

Case "Febuary"
Perform my actrions
Exit Sub
End Select
 
Back
Top