View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Edwin Tam[_7_] Edwin Tam[_7_] is offline
external usenet poster
 
Posts: 94
Default Test if value is between two numbers

The example test whether a number is between 50 and 100. It first assigns the
value to be tested to a variable "a". In the example, the value of the
selected cell is being tested.

Sub test()
Dim a
a = Selection.Value
If a 50 And a < 100 Then
MsgBox "Hello"
End If
End Sub


Regards,
Edwin Tam

http://www.vonixx.com

"smplogc" wrote:


What's the code to test if a value is between two numbers? I can easily
find the answer for other languages, but not VBA! TIA.


--
smplogc
------------------------------------------------------------------------
smplogc's Profile: http://www.excelforum.com/member.php...o&userid=33887
View this thread: http://www.excelforum.com/showthread...hreadid=537603