Thread: even
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1514_] Rick Rothstein \(MVP - VB\)[_1514_] is offline
external usenet poster
 
Posts: 1
Default even

You can also do it this way (execution should be marginally faster)...

MyVariable = 9
If MyVariable And 1 Then
MsgBox "Odd"
Else
MsgBox "Even"
End If

Rick


"Mike H" wrote in message
...
Use the MOD function

myvariable = 9
If (myvariable Mod 2) 0 Then
MsgBox "Odd"
Else
MsgBox "Even"
End If

Mike

"ranswert" wrote:

How do I find out if a variable is even?
Thanks