Select Case

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

Is this right?
Select Case
Case 1 To 4 or 6 or 8 or 10
Case 5 or 7
End Select

It seems to be working....Or should it be And
Select Case
Case 1 To 4 and 6 and 8 and 10
Case 5 and 7
End Select
Thanks
DS
 
Select Case
Case 1 To 4, 6, 8, 10
' Do this
Case 5, 7
' Do this
Case Else
' (9) Do this
End Select

In a Case statement, comma separated list acts similar to ORs, not ANDs. Any
condition not All conditions.
 
oops:

Select Case i

where i is the value being tested, presumably an integer between 1 and 10
inclusive.
 
Hmm, George. Like this?
Dim i As Integer
Select Case i
Case 1 To 4, 6,8,9
Case 5,7
End Select
 
Your right, it wasn't working. I didn't get an error message. but after
testing it always defaulted to the first case. The commas work fine.
Thanks
DS
 
Back
Top