Excel function

MODfunction

Returns the remainder after division. The result has the same sign as the divisor.

All versions
=MOD(A2, 4)
A
B
1
2
3
4
5
6
7

Click a cell in the table to change number. Click 15 and set divisor to 2: MOD becomes an odd/even test. Try breaking it on purpose to see the errors.

Result

3.14159

number
A2You can also click a cell in the table

The cell with the number to calculate. Click another value in the table.

divisor

The number to divide by. 0 returns #DIV/0!.

What is the MOD function?

=MOD(number, divisor)

MOD returns the remainder after division. Use it to test odd and even numbers or to mark every nth row.

According to Microsoft, the result has the same sign as the divisor and is calculated as MOD(n, d) = n - d*INT(n/d). So MOD(-3, 2) is 1, not -1.

Beyond odd and even, MOD handles anything that repeats: a three-shift rotation, a marker every n rows, a time span that crosses midnight. The result cycles from 0 up to just below the divisor, which makes it ideal for assigning numbers in a cycle.

Arguments

number
The number or cell to divide.
divisor
The number to divide by. 0 returns #DIV/0!.

MOD examples

  1. Example 1. Remainder

    =MOD(15, 4)

    15 divided by 4 leaves 3.

  2. Example 2. Odd or even

    =IF(MOD(A2, 2)=0, "Even", "Odd")

    A remainder of 0 after dividing by 2 means even.

  3. Example 3. Example from Microsoft

    =MOD(-3, 2)

    1. The result follows the sign of the divisor (2).

  4. Example 4. Three-shift rotation

    =MOD(ROW()-2, 3)+1

    Entered in row 2 and copied down, it cycles 1, 2, 3, 1, 2, 3…

    RowROW()-2MOD(…, 3)+1
    201
    312
    423
    531
  5. Example 5. Shift past midnight

    =MOD(B2-A2, 1)

    From 22:00 to 2:00 the next day gives 4:00 instead of a negative time.

Common mistakes

FAQ

How do I get the quotient?
Use =INT(A2/B2) or QUOTIENT.
Does it work with decimals?
Yes. MOD(3.14159, 1) returns the decimal part.