Function Math Arithmetic Class

NextEven

"Next Even Number" Returns the next larger even number.

Signature (Visual Basic / VBA)

Public Function NextEven( _
    ByVal vX As Variant _
    ) As Variant

Code Example

    NextEven(1) = 2
    NextEven(2) = 4
    NextEven(3) = 4
    NextEven(22.4) = 24
    NextEven(-1.7) = 0
    NextEven(-6.5) = -6
    NextEven(-7.8) = -6

Parameters

Parameter Description
vX Number which is rounded-up to the next even number (i.e. 2, 4, 6, -2, -4, -6, etc.). Function returns Null if vX is Null or cannot be fixed up to a number.

Notes & Version History

Note Similar to calling the Ceiling function with a precision of 2 (two), except that if vX is already an even number, this function returns the next even number.
Note Zero is considered an even number, as are all negative numbers divisible by two.