Can you believe that in VBA you cannot call MOD(a,b) function although it works fine in Excel cells??!
Well, you can use the operator a MOD b if both a and b are integer numbers.
But there is no direct MOD function in VBA because VBA 2003 does not support MOD (number, dividor) as a WorksheetFunction.
Therefore, I have to write the following function:
Function fmod(a As Double, b As Double)
fmod = a - b * (a \ b)
End Function
Subscribe to:
Post Comments (Atom)
MOD is an operator in VBA just like \, +, -, or *. It is not a function.
ReplyDeleteThe syntax is:
a MOD b