MOD Function in Excel

The MOD function returns the remainder from division. Perfect for determining even/odd numbers, creating patterns, and cycling sequences.

ExcelExcel
Google SheetsGoogle Sheets
math
beginner
Syntax Preview
ExcelExcelGoogle SheetsGoogle Sheets
=MOD(number, divisor)
What is the MOD Function?
Syntax and Parameters
How to Use MOD - Step by Step

Practical Examples

Check if Number is Even or Odd

Determine whether employee IDs are even or odd for team assignments

Result: "Odd"

Alternate Row Colors for Readability

Create zebra striping pattern in a large data table

Result: TRUE or FALSE (for conditional formatting)

Cycle Through Team Assignments

Distribute 50 projects evenly across 5 project managers

Result: "Manager Name"

Convert 24-Hour to 12-Hour Time

Display time in 12-hour format for reports

Result: "3 PM"

Group Data into Buckets

Divide 1,000 customers into 10 equal analysis groups

Result: Number between 1 and 10

Create Repeating Pattern Colors

Apply a 3-color pattern across product categories

Result: "Blue", "Green", or "Yellow"

Find Nth Occurrence with Remainder

Determine which week of month a date falls in

Result: Week number (1-5)

Common Errors and Solutions

#DIV/0!

Division by zero error in MOD function

Cause:

The divisor parameter is zero or a cell reference that contains zero

Solution:

1. Check that your divisor is not zero 2. Use IFERROR to provide a default value 3. Add validation to prevent zero divisors 4. Use an IF statement: =IF(B2=0, "Error", MOD(A2, B2))

Prevention:

Always validate divisor values before using MOD. For dynamic divisors, add a check: =IF(B2<>0, MOD(A2, B2), "Invalid divisor")

Frequency: 35%

Example:

#VALUE!

Invalid data type in MOD parameters

Cause:

One or both parameters contain text instead of numbers, dates formatted as text, or other non-numeric values

Solution:

1. Convert text numbers using VALUE() function 2. Check for hidden spaces with TRIM() 3. Verify cell formatting is set to Number 4. Use =MOD(VALUE(A2), VALUE(B2)) if cells contain text numbers 5. Remove any special characters or currency symbols

Prevention:

Use data validation to restrict cells to numeric input only. Check source data for text-formatted numbers by using ISNUMBER() function

Frequency: 30%

Example:

#NUM!

Result is too large or calculation error

Cause:

Extremely large numbers that exceed Excel's calculation limits (beyond 1E+308), or attempting to use MOD with values outside Excel's numeric range

Solution:

1. Check if input numbers are within Excel's range (-1E+308 to 1E+308) 2. Break down large calculations into smaller steps 3. Consider if you need scientific notation for display 4. Verify formulas feeding into MOD aren't returning errors

Prevention:

Keep numbers within reasonable ranges. For very large number operations, consider using logarithmic transformations or alternative calculation methods

Frequency: 5%

Example:

#REF!

Invalid cell reference in MOD formula

Cause:

Referenced cells have been deleted, moved, or the worksheet containing referenced cells has been removed. This often happens when copying formulas from other workbooks

Solution:

1. Check if all referenced cells exist 2. Update cell references to point to correct locations 3. Recreate the formula with current cell references 4. If copying from another workbook, ensure source data is available

Prevention:

Use named ranges instead of direct cell references for more stable formulas. When deleting rows/columns, check if any MOD formulas reference them

Frequency: 15%

Example:

Unexpected Negative Results

MOD returns negative numbers when you expected positive

Cause:

MOD's result takes the sign of the divisor. If divisor is negative, result will be negative. This is mathematically correct but can be unexpected

Solution:

1. Use ABS() to ensure positive divisor: =MOD(A2, ABS(B2)) 2. Or wrap entire result: =ABS(MOD(A2, B2)) 3. Use positive divisors unless you specifically need negative remainders 4. Understand that MOD(-10, 3) returns 2, not -1

Prevention:

Always use positive divisors for predictable positive remainders. If working with potentially negative numbers, apply ABS() to the divisor

Frequency: 10%

Example:

Best Practices and Advanced Techniques

Use MOD for Conditional Formatting Rules

MOD excels in conditional formatting for creating patterns. Use =MOD(ROW(), 2)=0 to highlight every other row, or =MOD(ROW(), 3)=0 for every third row. This creates professional-looking zebra stripes that automatically extend as you add data.

Combine with IF for Readable Results

Raw MOD results (0, 1, 2, etc.) aren't always intuitive. Wrap MOD in IF to create meaningful labels. For even/odd: =IF(MOD(A1,2)=0,"Even","Odd"). For quarters: =IF(MOD(MONTH(A1),3)=1,"Start",IF(MOD(MONTH(A1),3)=0,"End","Mid")).

Remember the -1, +1 Pattern for Natural Numbering

When cycling through items numbered 1-N (not 0 to N-1), use MOD(value-1, N)+1. This ensures your first item is 1, not 0. For example, assigning 100 tasks to 5 people (numbered 1-5): =MOD(A2-1, 5)+1.

Be Careful with Negative Numbers

MOD with negative dividends can produce unexpected results. MOD(-7, 3) returns 2, not -1, because the result takes the sign of the divisor. If you need traditional remainder behavior, use: =number - divisor*INT(number/divisor).

Performance: MOD is Lightning Fast

MOD is one of Excel's fastest functions. Unlike complex array formulas or VLOOKUP on large datasets, MOD performs calculations almost instantly even with millions of rows. Use it freely for row-by-row calculations without performance concerns.

Use Named Ranges for Divisors

When using the same divisor across many formulas (like MOD(A2, 7) for weekdays), create a named range for the divisor. This makes formulas more readable and easier to update. Change 'WeekLength=7' in one place instead of editing dozens of formulas.

MOD Works with Decimals

MOD isn't just for integers—it handles decimals perfectly. =MOD(7.5, 2.3) returns 0.6. This is useful for scientific calculations, measurement conversions, or any scenario with fractional remainders.

Create Dynamic Grouping with MOD and CHOOSE

Combine MOD with CHOOSE for powerful dynamic categorization. =CHOOSE(MOD(A1-1,3)+1,"Low","Medium","High") cycles through categories automatically. This technique works perfectly for priority levels, risk ratings, or any repeating classification system.

Related Functions

Need Help with MOD Function in Excel?

Stop struggling with formula syntax. Use AskFormulas to generate validated formulas instantly with our AI-powered tool.

Example Excel formula:

Related Formulas

ABS Function in Excel & Sheets

The ABS function returns the absolute value of a number, removing any negative sign. Learn syntax, examples, and common errors with this complete guide.

beginner
math
ExcelExcel
Google SheetsSheets
Validated
IF Function in Excel

Master the IF function with practical examples and error solutions. Learn conditional logic in Excel and Google Sheets for smarter decision-making.

beginner
logical
ExcelExcel
Google SheetsSheets
Validated
INT Function in Excel

The INT function rounds numbers down to the nearest integer by removing decimals. Learn syntax, practical examples, and error solutions.

beginner
math
ExcelExcel
Google SheetsSheets
Validated
ROUND Function in Excel

Master the ROUND function to round numbers to specified decimal places with practical examples and error solutions for Excel and Google Sheets.

beginner
math
ExcelExcel
Google SheetsSheets
Validated