David
asked on
VBA between statement
In VBA, how do I write an expression that limits BETWEEN to values. For example:
If [Lookup]= 1 to 10 Then msgbox "found it"
The above doesn't work in VBA but this is what I want to do. I want it to look for the values 1 to 10.
How can I make this work?
Thanks.
If [Lookup]= 1 to 10 Then msgbox "found it"
The above doesn't work in VBA but this is what I want to do. I want it to look for the values 1 to 10.
How can I make this work?
Thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So would the following work. Thanks for your patience.
Select Case [Lookup]
Case 1 to 10
If [Lookup] >= 1 AND [Lookup] <= 10 Then msgbox "Found 1-10"
Case 11 to 20
If [Lookup] >= 11 AND [Lookup] <= 20 Then msgbox "Found 11-20"
Case Else
msgbox "not found"
End Select
Select Case [Lookup]
Case 1 to 10
If [Lookup] >= 1 AND [Lookup] <= 10 Then msgbox "Found 1-10"
Case 11 to 20
If [Lookup] >= 11 AND [Lookup] <= 20 Then msgbox "Found 11-20"
Case Else
msgbox "not found"
End Select
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you.
A Select-Case block is like a very readable mega if-then-else block...
Thanks for the split. Good luck with your project. -Jim
ASKER