Google Sheets function · Math
MOD in Google Sheets: syntax and examples
MOD returns what is left after dividing one number by another. It is the tool for even or odd tests, for every nth row, and for cycles such as hours or weekdays. The sign of the result follows the divisor.
Syntax
MOD(dividend, divisor)
Arguments
| Argument | Type | Required | What it does |
|---|---|---|---|
dividend | number | yes | The number to divide. |
divisor | number | yes | The number to divide by. It cannot be 0. |
Examples
The examples use this table, starting in A1:
| Number | Divisor |
| 10 | 3 |
| -10 | 3 |
| 7.5 | 2 |
| 12 | 4 |
=MOD(A2, B2)Result: 1
10 divided by 3 leaves a remainder of 1.
Run in a Google Sheet (English US locale) on .
=MOD(A3, B3)Result: 2
A negative dividend: the result takes the sign of the divisor, so -10 mod 3 is 2.
Run in a Google Sheet (English US locale) on .
=MOD(10, -3)Result: -2
A negative divisor gives a negative remainder.
Run in a Google Sheet (English US locale) on .
=MOD(A4, B4)Result: 1.5
Decimals work too: 7.5 mod 2 is 1.5.
Run in a Google Sheet (English US locale) on .
=IF(MOD(A5, 2)=0, "even", "odd")Result: even
A classic use: the remainder after dividing by 2 tells even from odd.
Run in a Google Sheet (English US locale) on .
Common errors
- A divisor of 0 returns #DIV/0!. If the divisor comes from a cell that may be empty, test it first or wrap the formula in IFERROR.
- Negative numbers surprise people. MOD(-10, 3) is 2, not -1, because the result takes the sign of the divisor.
- A text that is not a number returns #VALUE!, and a missing divisor returns #N/A.
Compared with Excel
Same syntax as Excel MOD, and the result also takes the sign of the divisor.