Skip to content

MOD

Returns the remainder after dividing one number by another. The result has the same sign as the divisor.

Syntax

=MOD(, )

Math and trigonometry

All versions of Excel.

Try it

Edit the formula in C2 or change the inputs. The sheet recalculates as you type.

C2
A
B
C
D
1
Units
Per carton
Loose units
2
250
48
10
3

C2 =MOD(A2,B2) returns 10

How MOD works

MOD returns what is left over after a division. =MOD(17, 5) is 2, because 5 goes into 17 three times (15) with 2 remaining. The name stands for "modulo".

Where MOD is useful

  • Leftover units: =MOD(250, 48) is 10, the units that don't fill a carton of 48.
  • Even and odd: =MOD(B2, 2) is 0 for even numbers and 1 for odd ones. =IF(MOD(B2, 2)=0, "Even", "Odd") labels them.
  • Every nth row or item: =MOD(ROW(), 3)=0 is TRUE on every third row. Use it for banding or sampling.
  • Cycles: =MOD(B2-1, 7)+1 wraps a counter back to 1 after 7, so day 8 becomes day 1.
  • The time part of a date-time: =MOD(A2, 1) returns the fraction of the day.
  • Hours and minutes from minutes: =INT(B2/60) for hours and =MOD(B2, 60) for the minutes left.

The sign of the result

MOD(number, divisor) gives a result with the same sign as the divisor. With a positive divisor the result is never negative, even for a negative number: =MOD(-3, 5) is 2. With a negative divisor the result is zero or negative: =MOD(3, -5) is -2. This makes MOD the right tool for wrapping a value into a range, and it differs from the remainder some other languages give.

Excel defines MOD as number - divisor * INT(number/divisor). That explains the signs, because INT rounds negative quotients down.

MOD compared with its neighbours

  • QUOTIENT returns the whole-number part of the division, the other half of the answer.
  • INT with a division gives the same whole part for positive numbers.
  • ROUNDDOWN divides and drops the fraction.

Decimals and zero

MOD works with decimals: =MOD(8.5, 2) is 0.5. If the divisor is 0, MOD returns #DIV/0!, so guard cells that can be blank or zero with IF or IFERROR. Text such as "n/a" returns #VALUE!.

Arguments

number
The number you are dividing, such as B2.
divisor
The number you are dividing by, such as 2 or C2. If it is 0, MOD returns #DIV/0!.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Units left over after filling cartons

C2 =MOD(A2,B2)

Result: 10

48 x 5 = 240, so 10 of the 250 units are left over.

C2
A
B
C
D
1
Units
Per carton
Loose units
2
250
48
10
3

C2 =MOD(A2,B2) returns 10

Example 2

Negative numbers with a positive divisor

B2 =MOD(A2,5)

Result: 2

The result takes the sign of the divisor, so it is 2, not -3.

B2
A
B
C
1
Number
MOD by 5
2
-3
2
3

B2 =MOD(A2,5) returns 2

Example 3

Label a number as even or odd

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

Result: Odd

An even number leaves no remainder when divided by 2.

B2
A
B
C
1
Number
Type
2
17
Odd
3

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

Example 4

The time part of a date-time

B2 =MOD(A2,1)

Result: 18:00

Dividing by 1 leaves just the fraction of a day. Format the cell as time to show 18:00.

B2
A
B
C
1
Timestamp
Time of day
2
12-Feb-2025 18:00
18:00
3

B2 =MOD(A2,1) returns 18:00

Example 5

A zero divisor gives #DIV/0!

C2 =MOD(A2,B2)

Result: #DIV/0!

Dividing by zero isn't possible. Wrap the formula in IF(B2=0, "", MOD(A2,B2)) to avoid the error.

C2
A
B
C
1
Number
Divisor
Remainder
2
12
0
#DIV/0!
3

C2 =MOD(A2,B2) returns #DIV/0!

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In D2, return the units left over after filling cartons for the units in B2 and carton size in C2. Fill it down to D6.

Answer in D2, then it fills down to D6.

D2
A
B
C
D
E
F
1
Item
Units
Per carton
Loose units
Status
2
Pallet wrap
250
48
3
Gloves
100
25
4
Labels
61
12
5
Tape
500
48
6
Straps
90
30
7

Common mistakes

  • MOD(number, 0) returns #DIV/0!. A blank divisor cell counts as 0, so guard it with IF.
  • The sign follows the divisor, not the number. MOD(-3, 5) is 2, where some other tools return -3.
  • MOD works on decimals too, such as MOD(8.5, 2) = 0.5, but a decimal remainder from money or measurements may carry a tiny error. Wrap it in ROUND before you compare it with a fixed number.
  • MOD(ROW(), 2) and ROW() depend on where the formula sits. Insert a row above and the pattern shifts.
  • Text such as "12 units" returns #VALUE!. Keep units out of the number cell.

Questions people ask

What does MOD do in Excel?

It returns the remainder after division. MOD(17, 5) is 2, because 5 goes into 17 three times with 2 left.

How do I check whether a number is even or odd?

Use `=IF(MOD(B2, 2)=0, "Even", "Odd")`. MOD by 2 is 0 for even numbers and 1 for odd numbers.

How do I do something on every third row?

Test the row number: `=MOD(ROW(), 3)=0` is TRUE on rows 3, 6, 9 and so on. Use it in a helper column or in conditional formatting.

Why does MOD of a negative number give a positive result?

The result takes the sign of the divisor. MOD(-3, 5) is 2 because -3 = 5 x -1 + 2. For a remainder with the sign of the number, use `=B2-TRUNC(B2/C2)*C2`.

How do I get the whole-number part of a division?

Use QUOTIENT: `=QUOTIENT(250, 48)` is 5. MOD gives the remainder and QUOTIENT gives the number of whole divisions.

Learn MOD in a real sheet.

MOD is taught in Dates and financial modelling, lesson 9: Fiscal years and quarters. Each lesson is a short, graded exercise like the one above.