VBA equivalent to Excel's mod function

后端 未结 8 1165
抹茶落季
抹茶落季 2020-11-27 06:31

Is there a vba equivalent to excel\'s mod function?

相关标签:
8条回答
  • 2020-11-27 07:16

    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
    
    0 讨论(0)
  • 2020-11-27 07:19

    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

    0 讨论(0)
提交回复
热议问题