Excel MOD Function
MOD returns the remainder after dividing one number by another, and it's the go-to formula for spotting patterns like odd/even rows or repeating cycles.
MOD returns the remainder after one number is divided by another. If you divide 10 by 3, you get 3 with 1 left over. MOD gives you that leftover 1, not the 3.
Available in: Excel 365, Excel 2021, Excel 2019, and all earlier versions. MOD has been a standard Excel math function since Excel 97.
The "remainder" is whatever is left after dividing as many whole times as possible. Divide 17 by 5 and you get 3 whole times, with 2 remaining.
Syntax
=MOD(number, divisor)
| Parameter | Required | Description |
|---|---|---|
number | Yes | The value you're dividing. Can be a number, a cell reference, or a formula that returns a number. |
divisor | Yes | The value you're dividing by. If this is 0, MOD returns an error instead of a number. |
Basic Example
You're packing 137 units of a product into shipping boxes that hold 12 units each. You want to know how many units will be left over once you've filled as many full boxes as possible.
=MOD(137, 12)
// 137 = total units to pack
// 12 = units per box
This returns 5. Excel divides 137 by 12, gets 11 full boxes (132 units), and MOD reports the 5 units that don't fit into another full box.
How MOD Works
The result's sign matches the divisor
MOD's result always carries the same sign as the divisor, not the number being divided. =MOD(7, 3) returns 1. =MOD(-7, 3) returns 2, not -1, because the divisor is positive. =MOD(7, -3) returns -2.
This trips people up constantly. Excel doesn't calculate MOD the way a calculator's remainder button does. It uses the formula number - divisor * INT(number/divisor), and INT always rounds toward negative infinity, which is why the sign flips.
MOD works with decimals, not just whole numbers
=MOD(5.5, 2) returns 1.5. Both arguments can be decimals, and the result will be too. This makes MOD useful for anything involving fractional units, not just integers.
A divisor of 0 breaks the formula
There's no mathematical answer to "the remainder when dividing by zero," so MOD throws #DIV/0! in that case. This is the single most common error people hit with this function, and it's covered in detail below.
MOD and INT are connected
MOD is really just INT in disguise. Excel calculates it as number - divisor * INT(number/divisor). If you ever need to see the "whole number of times" instead of the remainder, use INT(number/divisor) alongside it.
Common Use Cases
Flag odd and even order numbers
You're auditing a list of order IDs and need to separate odd-numbered orders from even ones for a two-batch shipping run.
=IF(MOD(A2, 2) = 0, "Even", "Odd") // returns "Even" or "Odd" based on the order ID
Any number divided by 2 leaves a remainder of either 0 or 1. Zero means even, one means odd. This is faster than nesting a separate even/odd check.
Highlight every 4th row for shift grouping
You're scheduling warehouse staff into groups of 4 and want to shade the last row of every group in a conditional formatting rule.
=MOD(ROW(), 4) = 0
ROW() returns the current row number, and MOD checks whether it divides evenly by 4. Applied as a conditional formatting rule across your data, it shades row 4, row 8, row 12, and so on.
Convert total minutes into hours and leftover minutes
A call center logs total call duration in minutes, and you need to display it as "hours and minutes" instead of a raw number.
=INT(C2/60) & " hr " & MOD(C2, 60) & " min"
// C2 = total minutes logged
// INT(C2/60) = whole hours
// MOD(C2,60) = minutes left after removing whole hours
For 137 minutes, this returns 2 hr 17 min. INT handles the whole hours, MOD handles the remainder, and together they split one number into two readable parts.
Handling Errors
MOD throws #DIV/0! when the divisor argument is 0. This is the only error condition the function produces on its own.
Common causes of #DIV/0!:
- The divisor cell is blank or contains 0
- A formula feeding the divisor accidentally returns 0
- A lookup formula supplying the divisor failed to find a match and defaulted to 0
Since a zero divisor is the only thing that breaks MOD, test for it directly instead of wrapping the whole formula in IFERROR:
=IF(B2=0, "Check divisor", MOD(A2, B2))
Skip IFERROR here. It would also swallow errors that have nothing to do with a zero divisor, like a #REF! from a deleted cell or a #VALUE! from text sitting in the number argument. Testing B2 directly tells you exactly what went wrong.
Notes & Gotchas
Why does MOD return #DIV/0!?
This happens when the divisor argument is 0. There's no valid remainder when dividing by zero, so Excel can't calculate one and returns an error instead of a number. Check whether the divisor cell is blank, contains a literal 0, or is being fed by a formula that resolved to 0.
Why does MOD sometimes return a negative number?
MOD's result takes the sign of the divisor, not the number being divided. =MOD(-10, 3) returns 2, but =MOD(10, -3) returns -2. If you expected a positive remainder and got a negative one, check the sign of your divisor first.
Does MOD work with decimal numbers?
Yes. Both the number and the divisor can include decimals, and Excel returns a decimal remainder. =MOD(9.5, 2) returns 1.5. This makes MOD useful for measurements and quantities that aren't whole numbers, not just integer IDs.
How do I use MOD to check if a number is even or odd?
Divide by 2 and check the remainder. =MOD(A2, 2) = 0 returns TRUE for even numbers and FALSE for odd ones, since dividing any integer by 2 leaves a remainder of only 0 or 1.
What's the difference between MOD and QUOTIENT?
MOD returns the remainder after division. QUOTIENT returns the whole number result, with the remainder discarded entirely. =MOD(17, 5) returns 2, while =QUOTIENT(17, 5) returns 3. Use them together when you need both pieces, like converting minutes into hours and leftover minutes.
Related Functions
| Function | Use this when... |
|---|---|
INT | You need the whole-number result of a division instead of the remainder MOD returns. |
QUOTIENT | You want the division result truncated to an integer directly, without pairing INT with a separate division. |
Related Functions
Excel RAND and RANDBETWEEN Functions
Need random numbers for test data or simulations? RAND and RANDBETWEEN generate them instantly. Here's when to use each one.
Excel ROUND Function
ROUND changes a number's actual value, not just how it looks in a cell. Here's how the syntax works, when to use negative digits, and why formatting a cell isn't the same thing.
Excel ROUNDUP Function
ROUNDUP forces a number upward, no matter what the next digit is. Use it any time "close enough" isn't good enough, like packing boxes or billing hours.
Excel SUMIF Function
SUMIF adds up values in a range that meet one condition you specify. This guide covers the syntax, real formulas, and the mistakes that trip up beginners.