Excel MOD Function

The Excel MOD function returns the remainder after dividing a number by the divisor

Example: Excel MOD Function

Excel MOD Function

METHOD 1. Excel MOD Function using hardcoded values

EXCEL

=MOD(B5,2)
Result in cell D5 (0) - returns a remainder of 0 as 10 divided by 2 has no remainder (2 x 5 + 0 = 10).

=MOD(B6,3)
Result in cell D6 (1) - returns a remainder of 1 as 10 divided by 3 has a remainder of 1 (3 x 3 + 1 = 10).

METHOD 2. Excel MOD Function using links

EXCEL

=MOD(B5,C5)
Result in cell D5 (0) - returns a remainder of 0 as 10 divided by the value in cell (C5), which is 2, has no remainder (2 x 5 + 0 = 10).

=MOD(B6,C6)
Result in cell D6 (1) - returns a remainder of 1 as 10 divided by the value in cell (C6), which is 3, has a remainder of 1 (3 x 3 + 1 = 10).

METHOD 3. Excel MOD function using the Excel built-in function library with hardcoded values

EXCEL

Formulas tab > Function Library group > Math & Trig > MOD > populate the input boxes

=MOD(B6,3)
Note: in this example we are calculating the remainder of dividing 10 by 3, which derives with a remainder of 1 (3 x 3 + 1 = 10).
Built-in Excel MOD Function using hardocded values

METHOD 4. Excel MOD function using the Excel built-in function library with links

EXCEL

Formulas tab > Function Library group > Math & Trig > MOD > populate the input boxes

=MOD(B6,C6)
Note: in this example we are calculating the remainder of dividing 10 by the value in cell (C5), that has a value of 3, which derives with a remainder of 1 (3 x 3 + 1 = 10).
Built-in Excel MOD Function using links

METHOD 1. Excel MOD function using VBA with hardcoded values

VBA

Sub Excel_MOD_Function()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("MOD")

'apply the Excel MOD function
ws.Range("D5") = 10 Mod 2
ws.Range("D6") = 10 Mod 3

End Sub

OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named MOD.

ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell references ("D5") and ("D6") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.

METHOD 2. Excel MOD function using VBA with links

VBA

Sub Excel_MOD_Function()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("MOD")

'apply the Excel MOD function
ws.Range("D5") = ws.Range("B5") Mod ws.Range("C5")
ws.Range("D6") = ws.Range("B6") Mod ws.Range("C6")

End Sub

OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named MOD.
Number: Ensure that the number is captured in range ("B5:B6").
Divisor: Ensure that the corresponding divisor is captured in range ("C5:C6").

ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell references ("D5") and ("D6") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
Number: Select the numbers that you want to have divided by changing range ("B5:B6").
Divisor: Select the corresponding divisor by changing range ("C5:C6").

Usage of the Excel MOD function and formula syntax

EXPLANATION

DESCRIPTION
The Excel MOD function returns the remainder after dividing a number by the divisor.
SYNTAX
=MOD(number, divisor)
ARGUMENTS
number: (Required) The number that you want to divide.
divisor: (Required) The number to divide by.

ADDITIONAL NOTES
Note 1: The MOD function will return the same sign as the divisor.
Note 2: The MOD function returns a numeric value.
Note 3: If the divisor is 0, the MOD function will return an error (#DIV/0!).
Note 4: If the divisor or number arguments are text values the MOD function will return an error (#VALUE!).