Going Stellar

Home/Google Sheets reference

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

ArgumentTypeRequiredWhat it does
dividendnumberyesThe number to divide.
divisornumberyesThe number to divide by. It cannot be 0.

Examples

The examples use this table, starting in A1:

NumberDivisor
103
-103
7.52
124
=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.

Sources

  1. MOD (Docs Editors Help)

Markdown version · All functions