MOD function
MOD returns the remainder after division, with the sign of the divisor. It is common for odd/even tests, every-nth-row formatting and wrapping around a cycle.
Example
Read it as a sentence: divide -3 by 2 and return the remainder, which gives 1.
A
B
C
D
1
1
2
3
Syntax
MOD(number, divisor)
-
number(required) - The value to divide.
-
divisor(required) - What you divide by; zero gives #DIV/0!.
Returns: The remainder after division, with the sign of the divisor.
What Excel actually returns
Each formula below was run in desktop Excel. The result is exactly what the cell showed, errors included.
| Formula | Excel shows | Case |
|---|---|---|
=MOD(10,3) | 1 | 10,3 |
=MOD(-10,3) | 2 | -10,3 (sign of divisor) |
=MOD(10,-3) | -2 | 10,-3 |
=MOD(5.5,2) | 1.5 | Decimal 5.5,2 |
=MOD(0.3,0.1) | 0.1 | Float 0.3,0.1 |
=MOD("10","3") | 1 | Text number |
=MOD(10,0) | #DIV/0! | Divisor 0 |
=MOD(1E+15,7) | #NUM! | Huge 1E+15,7 |
Watch out for
- MOD(-3,2) is 1, not -1: the result takes the divisor's sign.
- MOD(n,2)=0 tests for even numbers.
Where it works
- Excel
- MOD is in every version of Excel from 2007 on.
- Google Sheets
- Same name, same behaviour for everyday use.
Part of Math and trig functions. Every result on this page was measured in desktop Excel, build 16.0.20527. Last updated .