using between 2 numbers in a case select

  • Thread starter Thread starter rikking
  • Start date Start date
R

rikking

Hello,
I was wondering if someone could help, I'm writing a case select wher
the first case is <50000, and the next one is between 50000 and 250000
I can't seem to figure out how to do between 2 numbers with a cas
select.
any help with this would be greatly appreciated

Cheers in advance

Ri
 
Hi Rik

you don't need to do the between ... if the value is less than 50000 it will
meet the first condition, then for the value to get to the second condition
it must be greater than (or equal to) 50000 ... so you only need to test if
it is less than 250000.

Select Case i
Case Is < 50000
MsgBox "i"
Case Is < 250000
MsgBox "ii"
End Select

Cheers
JulieD
 
Julie,

That approach will work nicely with continuous intervals, but what if there
are gaps in between?


Rick,

The syntax is:

Select Case i
Case Is < 50000
MsgBox "i"
Case 50001 To 250000
MsgBox "ii"
Case 500001 To 1000000
MsgBox "iii"
Case 2000000 To 2300000
MsgBox "iv"
End Select
 
then

Public Function twonumbercase(i)
Select Case i
Case 0 To 25000
twonumbercase = "i"
Case 25000 To 50000
twonumbercase = "ii"
Case Else
townumbercase = "Invalid"
End Select

End Function

25000 exactly will go to the first case.
 
Back
Top