Skip to content
Klargrid

The MOD function

The remainder of an integer division: 17 divided by 5, remainder 2. It is mostly used for what repeats in a cycle.

Syntax

=MOD(number, divisor)

In a French Excel: =MOD(nombre; diviseur).

Arguments

  • number: the dividend.
  • divisor: what to divide by; 0 returns #DIV/0!.

An example

=MOD(ROW(),2)=0

TRUE every other row: in conditional formatting, it shades every other row.

Pitfalls

  • A zero divisor: #DIV/0!.
  • With negatives, the result takes the divisor's sign: MOD(-1,3) returns 2.

Going further

  • INT, for the quotient.

Frequently asked questions

How do I calculate a duration that passes midnight?
=MOD(B2-A2,1): an end at 2:00 after a start at 22:00 gives 4:00, instead of a negative number.