Showing posts with label Odd and Even. Show all posts
Showing posts with label Odd and Even. Show all posts

Monday, 13 February 2012

Checking odd and even numbers in VBA

It is sometimes useful to be able to check whether a number is odd or even.

Below is a very simple VBA function that does exactly that:


Function IsOdd(x As Integer) As Boolean
'------------------------------------------------------------------------
' Procedure : IsOdd
' Author : Zypher.co.uk
' Date : 09-Feb-2012
' Purpose : Check whether a value is odd or even
'------------------------------------------------------------------------

   IsOdd = (x Mod 2) <> 0
End Function

As always, I hope it proves useful.