MOD Function
Purpose
Returns the remainder after a number is divided by a divisor ($\text{number} \pmod{\text{divisor}}$).
Syntax
EXCEL
=MOD(number, divisor)
Arguments Breakdown
| Argument | Required? | Description |
|---|---|---|
number |
Required | The number for which you want to find the remainder (dividend). |
divisor |
Required | The number by which you want to divide (must be non-zero). |
Practical Examples
1. Remainder Calculation Drill
From Formulas_&_Functions_Part_1.xlsx:
EXCEL
=MOD(30, 4)
Result: 2 (since $4 \times 7 = 28$, and $30 - 28 = 2$).
2. Alternating Row Shading (Zebra Striping)
In Conditional Formatting rules, highlight every even row:
EXCEL
=MOD(ROW(), 2) = 0
Highlight every 5th row:
EXCEL
=MOD(ROW(), 5) = 0
3. Extracting Time from a Date-Time Serial
In Excel, dates are whole integers and times are fractional decimals. To extract just the time:
EXCEL
=MOD(DateTimeCell, 1)
Gotchas & Behavior
- If
divisoris0,MODreturns the#DIV/0!error. - Sign behavior: The result of
MODtakes the sign of the divisor, not the number (e.g.,=MOD(-3, 2)returns1).
Related Knowledge
- Notes: 02 Statistical and Aggregation Functions
- Workbook:
11_Demos_and_Workbooks/03_Formulas_and_Functions/Formulas_&_Functions_Part_1.xlsx(Sheet:Arithmetic and statistical)