View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Nick Hodge Nick Hodge is offline
external usenet poster
 
Posts: 1,173
Default IF statement to check against list of values

Dan

IN is a SQL command, try a select case statement

Sub SelectCase()
Select Case var1
Case Is = "XXX"
MsgBox "XXX"
Case Is = "YYY"
MsgBox "YYY"
Case Is = "ZZZ"
MsgBox "ZZZ"
Case Else
MsgBox "Something Else"
End Select
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk


"Dan" wrote in message
...
I'm looking to right an if statment in VBA that accomplishes this;

IF var1 IN ("XXX", "YYY", "ZZZ") THEN
DoThing1
ELSE
DoThing2
Endif

I tried it as above, and it didn't like the use of "IN"