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 =MOD(A2,B2) returns 10
Returns the remainder after dividing one number by another. The result has the same sign as the divisor.
Syntax
=MOD(, )
All versions of Excel.
Try it
Edit the formula in C2 or change the inputs. The sheet recalculates as you type.
C2 =MOD(A2,B2) returns 10
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".
=MOD(250, 48) is 10, the units that don't fill a carton of 48.=MOD(B2, 2) is 0 for even numbers and 1 for odd ones. =IF(MOD(B2, 2)=0, "Even", "Odd") labels them.=MOD(ROW(), 3)=0 is TRUE on every third row. Use it for banding or sampling.=MOD(B2-1, 7)+1 wraps a counter back to 1 after 7, so day 8 becomes day 1.=MOD(A2, 1) returns the fraction of the day.=INT(B2/60) for hours and =MOD(B2, 60) for the minutes left.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 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!.
B2.2 or C2. If it is 0, MOD returns #DIV/0!.Each example is a live sheet. Change the inputs or the formula and watch the result.
Example 1
C2 =MOD(A2,B2)
Result: 10
48 x 5 = 240, so 10 of the 250 units are left over.
C2 =MOD(A2,B2) returns 10
Example 2
B2 =MOD(A2,5)
Result: 2
The result takes the sign of the divisor, so it is 2, not -3.
B2 =MOD(A2,5) returns 2
Example 3
B2 =IF(MOD(A2,2)=0,"Even","Odd")
Result: Odd
An even number leaves no remainder when divided by 2.
B2 =IF(MOD(A2,2)=0,"Even","Odd") returns Odd
Example 4
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 =MOD(A2,1) returns 18:00
Example 5
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 =MOD(A2,B2) returns #DIV/0!
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.
#DIV/0!. A blank divisor cell counts as 0, so guard it with IF.#VALUE!. Keep units out of the number cell.It returns the remainder after division. MOD(17, 5) is 2, because 5 goes into 17 three times with 2 left.
Use `=IF(MOD(B2, 2)=0, "Even", "Odd")`. MOD by 2 is 0 for even numbers and 1 for odd numbers.
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.
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`.
Use QUOTIENT: `=QUOTIENT(250, 48)` is 5. MOD gives the remainder and QUOTIENT gives the number of whole divisions.
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.