View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
dominicb[_42_] dominicb[_42_] is offline
external usenet poster
 
Posts: 1
Default VBA code for IF statement with OR?


Good evening Dave R

This is how to do what you are asking. The code will throw up a
message box containing the value of Var, only if Var1=23 or 34, so
change the value of Var1 and re-run the code to see the routine in
action.

Sub Demo()
Var1 = 23 'Change this value and re-run the code
If Var1 = 23 Or Var1 = 34 Then
Var = "Hello"
MsgBox Var
End If
End Sub

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=382126