Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Between Function

Status
Not open for further replies.

Ascentient

IS-IT--Management
Nov 4, 2002
267
I am looking for a function in VBA that will check to see if the results of a calculation is between a range. I cannot seem to locate anything in the help file or from searches on the forumn.

Any suggestions other than the x > y and x < z approach?
 
What is wrong with the x > y and x < z approach?
 
Nothing. I just recall from another language that there was a function to do this, and I could not find one in VBA.

 
In fact, the right way in VBA is:
x >= y and x <= z

You may write your own function to emulate the Between [!]operator[/!] ...
 


"other language" YES.

In Structured Query Language there is a Between OPERATOR, but not in VB.

Skip,

[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue]
 
Here you go, see help on CASE, very versatile.

Dim IntValue as Integer
IntValue = 5 + 6

Select Case IntValue
Case 1 To 10
'blah
Case 11 To 12
'blah
Case Else
'blah
End Select
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top