Excel MOD Function
The Excel MOD function returns the remainder after dividing a number by the divisor
Example: Excel MOD Function
=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).
|
=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
=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). |
METHOD 4. Excel MOD function using the Excel built-in function library with links
EXCEL
=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). |
Dim ws As Worksheet
ws.Range("D5") = 10 Mod 2
ws.Range("D6") = 10 Mod 3
End Sub
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.
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.
Dim ws As Worksheet
ws.Range("D5") = ws.Range("B5") Mod ws.Range("C5")
ws.Range("D6") = ws.Range("B6") Mod ws.Range("C6")
End Sub
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.
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").
The Excel MOD function returns the remainder after dividing a number by the divisor.
=MOD(number, divisor)
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!).