View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Toby Erkson[_3_] Toby Erkson[_3_] is offline
external usenet poster
 
Posts: 24
Default Using SELECT...CASE with comparison operators?

C'mon Tom, it was example code, I was trying to be generic. How could I have
made it more helpful -- what would you suggestion?

Actually, your code comments were perfect :-) Thanks for the help!

Arvi, I actually have a lot more conditions and resulting statements so your
example isn't even feasible (which is why I asked for SELECT...CASE), however,
thanks for the alternative simple solution :-)
--
Toby Erkson
Oregon, USA
Excel 2002 in Windows XP

"Tom Ogilvy" wrote in message
...



The example code didn't help:

Dim Number
Number = 8 ' Initialize variable.
Select Case Number ' Evaluate Number.
Case 1 To 5 ' Number between 1 and 5, inclusive.
Debug.Print "Between 1 and 5"
' The following is the only Case clause that evaluates to True.
Case 6, 7, 8 ' Number between 6 and 8.
Debug.Print "Between 6 and 8"
Case 9 To 10 ' Number is 9 or 10.
Debug.Print "Greater than 8"
Case Else ' Other values.
Debug.Print "Not between 1 and 10"
End Select

You would substitute Widgets for Number in the above and adjust you range of
numbers (utilize the syntax of Case 1 to 5)


--
Regards,
Tom Ogilvy

....