MOD function
The MOD function in Excel returns the remainder after a number is divided by a divisor. It is commonly used in mathematical operations where you need to determine the remainder of division.
Syntax
=MOD(number, divisor)
Parameters
number: The number that you want to divide. This can be a value or a reference to a cell that contains a number.divisor: The number by which you want to divide thenumber. This can also be a value or a reference to a cell containing the divisor.
Return Value
The MOD function returns the remainder after dividing the number by the divisor. If the division is exact (i.e., there’s no remainder), the function returns 0.
How It Works
The result is the remainder from the division of number by divisor.
For example:
- If you divide 10 by 3, the remainder is 1 (since 3 goes into 10 three times, with 1 left over).
- If you divide 12 by 4, the remainder is 0 (since 12 is exactly divisible by 4).
Example Usage
Example 1: Basic Division with Remainder
To find the remainder when 10 is divided by 3:
=MOD(10, 3)
The result will be:
1
Explanation: 10 ÷ 3 = 3 remainder 1, so the result is 1.
Example 2: Division with Exact Quotient
To find the remainder when 12 is divided by 4:
=MOD(12, 4)
The result will be:
0
Explanation: 12 ÷ 4 = 3 with no remainder, so the result is 0.
Example 3: Negative Numbers
The MOD function also works with negative numbers. The result will always have the same sign as the divisor.
For example: To find the remainder when -10 is divided by 3:
=MOD(-10, 3)
The result will be:
2
Explanation: -10 ÷ 3 = -4 remainder 2. The result is positive because the divisor (3) is positive.
Example 4: Using Cell References
If cell A1 contains the value 20, and cell A2 contains the value 6, you can use:
=MOD(A1, A2)
The result will be:
2
Explanation: 20 ÷ 6 = 3 remainder 2.
Key Notes
- The MOD function is useful for operations like determining if a number is even or odd, checking periodic intervals, or working with dates and times.
- If the divisor is 0, the MOD function will return a #DIV/0! error.
- The result of the MOD function always has the same sign as the divisor.
Common Uses
- Check for Even or Odd Numbers: You can use MOD(number, 2) to determine if a number is even (returns 0) or odd (returns 1).
- Time Calculations: When working with time, the MOD function can be used to calculate remaining time or divide time intervals.
- Repetition: When working with tasks that repeat after a certain interval, you can use MOD to determine at which point you are in the cycle.
Example in a Real-World Scenario:
To check if a given date (in A1) falls on a weekend, you can use:
=IF(MOD(WEEKDAY(A1), 7) > 5, "Weekend", "Weekday")
This checks the remainder when the weekday number is divided by 7, indicating if it’s a Saturday or Sunday (weekend).