View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Using "case" code in Excel

Do you really have MONDAY in J2? All upper case???

If it's not all upper case, ...

select case lcase(r.value)
case is = lcase("monday")
call MondayMacro
case is = lcase("tuesday")
....



Howard wrote:

I have the following problem. Cell J2 contains a drop-down menu of week
days. I am trying to use VBA to check the text in cell J2, and then run a
macro that matches the week day. The code follows, but it doesn't seem to
work. Any suggestions?

Sub selectthecase()

Dim r As Range
Set r = Range("J2")

Select Case r
Case Is = "MONDAY"
Call MondayMacro
Case Is = "TUESDAY"
Call TuesdayMacro
Case Is = "WEDNESDAY"
Call WednesdayMacro
Case Is = "THURSDAY"
Call ThursdayMacro
Case Is = "FRIDAY"
Call FridayMacro
Case Is = "SATURDAY"
Call SaturdayMacro
End Select

End Sub
--
Howard


--

Dave Peterson