Is there a vba equivalent to excel\'s mod
function?
But if you just want to tell the difference between an odd iteration and an even iteration, this works just fine:
If i Mod 2 > 0 then 'this is an odd
'Do Something
Else 'it is even
'Do Something Else
End If
My way to replicate Excel's MOD(a,b)
in VBA is to use XLMod(a,b)
in VBA where you include the function:
Function XLMod(a, b)
' This replicates the Excel MOD function
XLMod = a - b * Int(a / b)
End Function
in your VBA Module