View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
William Horton
 
Posts: n/a
Default Anyone actually get Case statement to work ... ?

Not sure if this is what you want/need but it works for me in a macro.

Sub test()
Dim MWS As Worksheet, X As String
Set MWS = ThisWorkbook.Worksheets(1)
Select Case MWS.Range("A1")
Case 1
MsgBox "case was 1"
Case 2
MsgBox "case was 2"
Case 3
MsgBox "case was 3"
Case Else
MsgBox "case was not 1 or 2 or 3"
End Select
End Sub

Hope that is a start.

"ForestFeeder" wrote:

Has anyone successfully used the Case statement in a select query using MS
SQL within Excel , looking at an excel file as a datasource?

I'd love for you to post a sample query that you got to work. I've followed
the syntax every which way and it doesnt seem to work on this configuration.
Much appreciated !