Function Math Arithmetic Class

NextOdd

"Next Odd Number" Returns the next larger odd number.

Signature (Visual Basic / VBA)

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

Code Example

    NextOdd(0) = 1
    NextOdd(1) = 3
    NextOdd(2) = 3
    NextOdd(45) = 47
    NextOdd(22.4) = 23
    NextOdd(-1.7) = -1
    NextOdd(-6.5) = -5
    NextOdd(-7.8) = -7

Parameters

Parameter Description
vX Number which is rounded-up to the next odd number (i.e. 1, 3, 5, -1, -3, -5, 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) and an offset of 1 (one), except that if vX is already an odd number, this function returns the next odd number.