MODULUS Function in Excel – Shiksha Online

MODULUS Function in Excel – Shiksha Online

5 mins read3.2K Views Comment
Rashmi
Rashmi Karan
Manager - Content
Updated on Mar 3, 2023 13:33 IST

The article will help you understand how the MODULUS function or MOD function in Excel works through some interesting datasets.

2022_06_MODULUS-Function-in-Excel-1.jpg

The MODULUS function in Excel will help you get the remainder of an inexact division. MOD function in Excel allows obtaining the remainder from the division of two numbers. It is a built-in function in MS Excel and is categorized as a Math/Trigonometry function. We can also use it as a worksheet function in Excel, which means that we can enter the MODULUS function in Excel as a part of a formula in a cell of a worksheet.

Content

MODULUS Formula in Excel

The syntax of the MOD function is:

=MOD(number, divisor)

Where, 

Number = The number for which you want to find the remainder. It is a mandatory argument.

Divisor = The number by which you will divide the Number. Another mandatory argument.

Remember –

  • If the divisor is zero, the MOD function will return an error value, which is #DIV/0! 
MODULUS Formula in Excel 1
  • If the number or divisor is text, the MOD function returns the #VALUE! Error
MODULUS Formula in Excel 2

Most Popular and Powerful Formulas in Excel
How to Create MIS Report in Excel?
Index and Match in Excel – Shiksha Online
Recommended online courses

Best-suited MS Excel courses for you

Learn MS Excel with these high-rated online courses

12 K
2 months
– / –
3 months
5.5 K
18 hours
60.55 K
10 months
1 L
6 months
3.2 K
28 hours
– / –
45 hours
4.3 K
2 months
1.34 L
300 hours

Examples – Use of the MODULUS function in Excel

You can use the MOD function by placing the exact numbers that you want to divide in their respective arguments, or by indicating the numbers of the Excel cells on which you want to perform the division.

Read MS Excel Tutorials

Basic Calculations using the MOD function

In the below example, you can see that =MOD(12,5) returns 2 because when you divide 12 by 5, you get a quotient of 3 and a remainder of 2 (12=5*2+1). The formula MOD(12,2) returns zero because 12 is divided by 2 without remainder, similarly, 12 is divided by 3, 4, and 6 without any remainder.

Basic Calculations using the MOD function 1

MOD formula to sum every Nth row or column

Excel does not have any function to sum 2nd, 3rd, and so on rows. We can achieve this by incorporating the MOD function.

To sum every second row, we can use MOD with ROW and SUMPRODUCT:

Sum even rows:

=SUMPRODUCT((MOD(ROW(range),2)=0)*(range))

Sum odd rows:

=SUMPRODUCT((MOD(ROW(range),2)=1)*(range))

Assuming B3:B9 are the cells to sum, the formulas look as follows:

Even rows

=SUMPRODUCT((MOD(ROW($B$3:$B$9),2)=0)*($B$3:$B$9))

MOD formula to sum every Nth row or column

Odd rows

=SUMPRODUCT((MOD(ROW($B$3:$B$9),2)=1)*($B$3:$B$9))

MOD formula to sum every Nth row or column 2

The combination of MOD and ROW determines which rows to sum.

SUMPRODUCT adds up the values.

Tutorial – XLOOKUP in Excel – Shiksha Online
How to Import Text Files to Excel
How To Calculate Percentage In Excel

Sum Every Nth Column

If you have a dataset where you want to add up numbers in every Nth column, just replace ROW with COLUMN in the formula that we used in the previous example –

=SUMPRODUCT((MOD(COLUMN(range)-COLUMN(first_cell)+1,n)=0)*(range))

For the below dataset of the student’s scores in different exams, we have to calculate how much did they score in their quarterly and half-yearly exams. Here, we need to sum up numbers in every 4th column in the range B2:L2, you go with this formula:

=SUMPRODUCT((MOD(COLUMN($B2:$L2)-COLUMN($B2)+1,4)=0)*($B2:$L2))

Sum Every Nth Column 1

Press enter and drag down to apply the formula to the remaining cells and get the annual result for every student.

Sum Every Nth Column 2

Concatenate Every Nth Column

We can use the MOD formula to concatenate every N cell. This feature is particularly useful if some of the details of any product/item are spread across different cells. If you have a long list of such products then it gets a challenging task and here is where the MOD formula comes in. 

In the below example, we have a list of products within a retail company and the data needs to be sorted as per product details. These details are already available under Order Detail in Column B, and the MOD function will help to CONCATENATE these details to create the product IDs. 

Concatenate Every Nth Column 1

We will use the MOD formula with the IF function.

=IF(MOD(ROW()-1, 3)=0, CONCATENATE(B2, “-“, B3, “-“, B4), “”)

Concatenate Every Nth Column 2

You should note that you should enter the formula next to the last row of data, C4, here. Copy the formula down the column and the MOD function will concatenate the contents of the cells.

CONCATENATE in Excel – Shiksha Online
Import Data from PDF to Excel – Shiksha Online
Power Query in Excel – Shiksha Online

To create a formula like this, you first need to check if the row can be divisible by 3 and leaves no remainder.

=MOD(ROW()-1, 3)=0

We will then subtract 1 from the actual row number so that we get the relative position of the current row. So, IF, the remainder is 0, we will apply the concatenate function for B2, B3, and B4. These rows will be separated by a delimiter (“-” here). We use relative cell references to ensure that three different cells are concatenated every time the formula is used.


Top Trending Articles in MS Excel:

Most Useful Excel Formulas | Min Max Functions in Excel | Average Functions in Excel | Introduction to MS Excel | Financial Modelling in Excel | MS Excel interview questions | Sum Function in Excel | Trim Function in Excel | Pivot Table in Excel | Percentage in Excel | Vlookup in Excel | Median Function in Excel | Types of Charts in Excel | Count Function in Excel | MS Excel Vs. Google Sheet | Remove Duplicates in Excel | Create Graph in Excel

FAQs

What is the modulus function?

A modulus function gives the absolute value of a number or variable and is regarded as an absolute value function. The MOD function produces the magnitude of the number of variables.

What is the use of the MOD function in Excel?

The MOD function in Excel is a mathematical function that helps to find a remainder after a dividend is divided by a divisor. This function is helpful when we have to process every nth value.

What is the opposite of the MOD function in Excel?

Many people are unaware of the fact that there is a function that is opposite to the MOD function in Excel. The QUOTIENT function is helpful if you want to return the opposite, the integer part of a division.

Is modulus always positive?

The Absolute (ABS) function in Excel returns the absolute value of a number. In simpler words, the ABS function removes the minus sign (-) from a negative number, thus making the modulus positive.

What is ABS in Excel formula?

The ABS function in Excel returns the absolute value of a number. It converts negative numbers to positive numbers, without affecting the positive numbers.

About the Author
author-image
Rashmi Karan
Manager - Content

Rashmi is a postgraduate in Biotechnology with a flair for research-oriented work and has an experience of over 13 years in content creation and social media handling. She has a diversified writing portfolio and aim... Read Full Bio