Purpose
Return value
Syntax
=MOD(number,divisor)
- number - The number to be divided.
- divisor - The number to divide with.
Using the MOD function
The MOD function returns the remainder after division. For example, MOD(3,2) returns 1, because 2 goes into 3 once, with a remainder of 1.
The MOD function takes two arguments: number and divisor. Number is the number to be divided, and divisor is the number used to divide. Both arguments are required. If either argument is not numeric, the MOD function returns #VALUE!.
Equation
The result from the MOD function is calculated with an equation like this:
=n-d*INT(n/d)
where n is number , d is divisor , and INT is the INT function. This can create some unexpected results because of the way that the INT function rounds negative numbers down, way from zero:
=MOD(7,3) // returns 1
=MOD(7,-3) // returns -2
MOD with negative numbers is implemented differently in different languages.
Examples
Below are some examples of the MOD function with hardcoded values:
=MOD(12,3) // returns 0
=MOD(12,5) // returns 2
=MOD(100,33) // returns 1
=MOD(6.25,1) // returns 0.25
Negative numbers
The result from MOD carries the same sign as divisor . If divisor is positive, the result from MOD is positive, if divisor is negative, the result from MOD is negative:
=MOD(-3,2) // returns 1
=MOD(3,-2) // returns -1
=MOD(-3,-2) // returns -1
Time from datetime
The MOD function can be used to extract the time value from an Excel date that includes time (sometimes called a datetime ). With a datetime in A1, the formula below returns the time only:
=MOD(A1,1) // return time only
Detailed explanation here .
Large numbers
With very large numbers, you may see the MOD function return a #NUM error. In that case, you can try an alternative version based on the INT function:
=number-(INT(number/divisor)*divisor)
Notes
- MOD is often seen in formulas that deal with “every nth” value
- MOD is useful for extracting the time from a date
- MOD always returns a result in the same sign as the divisor .
- MOD will return a #DIV/0! error if divisor is zero
- To discard the remainder and keep the integer, see the QUOTIENT function .
Purpose
Return value
Syntax
=MROUND(number,significance)
- number - The number that should be rounded.
- significance - The multiple to use when rounding.
Using the MROUND function
The MROUND function rounds a number to the nearest given multiple. The multiple to use for rounding is provided as the significance argument. Rounding occurs when the remainder from dividing number by significance is greater than or equal to half the value of significance. If the number is already an exact multiple, no rounding occurs and the original number is returned.
The MROUND function takes two arguments , number and significance . Number is the numeric value to round. The significance argument is the multiple to which number should be rounded. In most cases, significance is provided as a numeric value, but MROUND can also understand time entered as text like “0:15” or “0:30”. Number and significance must have the same sign, otherwise MROUND will return a #NUM! error.
Examples
Below are some examples of MROUND formulas with hardcoded values:
=MROUND(10,3) // returns 9
=MROUND(10,4) // returns 12
=MROUND(119,25) // returns 125
To round a number in A1 to the nearest multiple of 5, you can use MROUND like this:
=MROUND(A1,5) // round to nearest 5
Nearest negative number
To round negative numbers with MROUND, use a negative sign for significance:
=MROUND(-10,-3) // returns -9
=MROUND(-10,-4) // returns -12
=MROUND(-119,-25) // returns -125
Nearest .99
MROUND can be used to round pricing to end with .99. The formula below will round a value in A1 to the nearest 1 dollar, subtract 1 cent, and return a final price like $2.99, $5.99, $49.99, etc.
=MROUND(A1,1) - 0.01 // round to nearest .99
Nearest 15 minutes
MROUND can be used to round time. To round a time in A1 to the nearest 15 minutes, you can use a formula like this:
=MROUND(A1,"0:15") // round to nearest 15 min
Rounding functions in Excel
Excel provides a number of functions for rounding:
- To round normally, use the ROUND function .
- To round to the nearest multiple, use the MROUND function .
- To round down to the nearest specified place , use the ROUNDDOWN function .
- To round down to the nearest specified multiple , use the FLOOR function .
- To round up to the nearest specified place , use the ROUNDUP function .
- To round up to the nearest specified multiple , use the CEILING function .
- To round down and return an integer only, use the INT function .
- To truncate decimal places, use the TRUNC function .
Notes
- If a number is already an exact multiple, no rounding occurs.
- Rounding occurs when the remainder from dividing number by significance is greater than or equal to half the value of significance.
- Number and significance must have the same sign.
- MROUND returns #NUM! if number and significance are not the same sign.
- MROUND returns #VALUE! if number or significance is not numeric.