Thread: Odd or Even
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_7_] Bob Phillips[_7_] is offline
external usenet poster
 
Posts: 1,120
Default Odd or Even

Public Function IsOdd(Val) As Boolean
IsOdd = (Val \ 2) * 2 < Val
End Function


--
HTH

Bob Phillips

"MIKE215" wrote in message
...
Hi PraxisPete

You can use the MOD operator to return the remainder of a division by 2
VAR1 = 13
ANS = VAR1 MOD 2
and test the value of ANS. ANS = 1 and is odd in this case.

Regards,
Mike

"PraxisPete" wrote:

Hi Everybody
I think this should be straight forward but brain is just not working

today
How can I use VBA code to determine if the contents of a varible is odd

or
even?

Many thanks