Finance

Charts

Statistics

Macros

Search

How to use the MOD() Function in Excel

The MOD returns the remainder after division of number by divisor, preserving the sign of the divisor.

Syntax

MOD(number; divisor)

Arguments

Parameter Requirement Valid Input
number Required Any real number (dividend)
divisor Required Non-zero real number

Key Properties

  1. Mathematical Definition:

    • Sign Rule: Result carries the sign of divisor.
    • Special Case: MOD(n, 1) returns the decimal part of n.
  1. Error Handling:
    • #DIV/0! if divisor = 0.
  2. Behavior for Negatives:
Example Result Explanation
=MOD(7,3) 1 Standard case
=MOD(-7,3) 2 Follows divisor’s sign (+)
=MOD(7,-3) -2 Follows divisor’s sign (–)
=MOD(-7,-3) -1 Follows divisor’s sign (–)

Examples

The MOD() function is often used together with other functions; for example, to add every second line (see Figure below).

The formula is {=SUM(IF(MOD(ROW(C3:C8);2)=0;C3:C8;0))}. Because this is an array formula, you have to press Ctrl+Page Up+Enter after you enter the formula.

Comparison with Other Methods

Method Formula -7 mod 3 Sign Rule
Excel MOD n – d*INT(n/d) 2 Matches divisor
Symmetrical n – d*TRUNC(n/d) -1 Matches dividend

Applications

  • Alternate Row Shading:

=MOD(ROW(),2)=0 → Conditional formatting rule 

  • Time Calculations: Convert seconds to HH:MM:SS.
  • Circular Buffers: Index wrapping in programming.
0 0 votes
Évaluation de l'article
S’abonner
Notification pour
guest
0 Commentaires
Le plus ancien
Le plus récent Le plus populaire
Online comments
Show all comments
Facebook
Twitter
LinkedIn
WhatsApp
Email
Print
0
We’d love to hear your thoughts — please leave a commentx