Home > Uncategorized > MOD Function and Mod Operator Return Different Values

MOD Function and Mod Operator Return Different Values

February 8th, 2006 Leave a comment Go to comments

I didn’t know this before today when an user at MrExcel wondered why he was not getting consistent answers with Excel and VBA. The key is negative numbers.

If you happen to have negative numbers (one of them) and you want to calculate MOD, you should use this code in VBA

yourmodval=n-d*INT(n/d)

Where n is your number and d is your divisor.

For more info, check:
MOD Function and Mod Operator Return Different Values

Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.