View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Using SELECT...CASE with comparison operators?




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



"Toby Erkson" wrote in message
...
Can I convert the following IF...THEN statements to a SELECT...CASE?

if wigets = 20 AND wigets < 200 then...
if wigets =200 AND wigets < 400 then...
if wigets = 400 AND wigets < 600 then...

Excel help wasn't too helpful. I tried unsuccessfully to use TO and IS.

I
don't think I understand them very well.

Thanks,
Toby Erkson
Oregon, USA
Excel 2002 in Windows XP