How to get the Sum of odd numbers? How to get the sum of even numbers?

In this article, we will learn to How to Sum Odd / Even Numbers In Excel.

Scenario:

Working with numbers data, Sometimes we need to get the sum of odd numbers or sum of even numbers in the list. Like getting the sum of values corresponding to the odd numbers or even numbers in the dateset. For this we can use the basic sense of odd and even numbers i.e odd numbers leaves a remainder 1 when divide by 2 whereas even numbers leave 0 as remainder when divided by 2.

Functions used and formula Syntax:

The following function will be in use. So get to know a little about, before using it.

  1. SUMPRODUCT function
  2. MOD Function

We will construct a formula out of it. Firstly, the MOD function takes the remainder of value by 2 ( divisibility factor ) and. SUMPRODUCT function returns the sum of corresponding values to TRUE values (as 1) and ignore values corresponding to FALSE values (as 0) in the array.

Use the formula:

=SUMPRODUCT(--(MOD(range,2)=1),range)

= 1 : count of odd numbers ( even numbers : use = 0 )

range : range of values to check for 

Example:

All of these might be confusing to understand. So, let's test this formula via running it on the example shown below. Here we need to find the sum of numbers listed in range. For that we have a list of numbers and we will get the Sum of odd numbers in the list using the formula. Now we will use the formula below to get the sum of values in the table satisfying the mentioned criteria.

Formula:

= SUMPRODUCT(--(MOD(C3:C17,2)=1),C3:C17)

Explanation:

  • MOD Function matches remainder with xero value for each value in range.
  • Negation sign changes True to False values and False to True values.
  • MOD function takes single input and single output (remainder) but we want an array of values for the input range. Negation (--) character helps it do it.
  • SUMPRODUCT function returns the sum of corresponding values to TRUE values (as 1) and ignore values corresponding to FALSE values (as 0) in the returned array.

Here the arrays to the function are given as array reference. Use double (--) manually Press Enter to get the result.

As you can see in the above snapshot the sum comes out to be 24736. This is the sum to the corresponding odd numbers in the range wherever it lies. Now to see below to find the sum having even numbers.

Sum of even numbers :

How to get the sum of even numbers in excel. We will use the same formula we used to calculate for the odd numbers. Just use the =0 instead for = 1. As the remainder must be 0 for the even numbers when divided by 2.

Use the formula:

=SUMPRODUCT(--(MOD(C3:C17,2)=0),C3:C17)

range : range of values to check for

As you can see in the above snapshot the sum of odd numbers on the left and sum of numbers on the right side under the sum column.

Criteria column and sum column be different in formula:

Sum of odd row number:

We can use the different ranges for the criteria in MOD function and SUM from other range. For this we will have another index list which will be our criteria. Use the below formula to get the sum of numbers having odd number rows.

Use the formula:

=SUMPRODUCT(--(MOD(B3:B17,2)=1),C3:C17)

B3:B17 : range of values to check for.

C3:C17 : range to sum values.

As you can see in the above snapshot the addition comes out to be 52783. This is the sum to the corresponding odd row numbers in the range wherever it lies. Now to see below to find the sum having even row numbers.

Sum of even row numbers :

How to get the sum of even row numbers in excel. We will use the same formula we used to calculate for the odd row numbers. Just use the =0 instead for = 1. As the remainder must be 0 for the even numbers when divided by 2.

Use the formula:

=SUMPRODUCT(--(MOD(B3:B17,2)=0),C3:C17)

B3:B17 : range of values to check for.

C3:C17 : range to sum values.

As you can see in the above snapshot the sum of odd row numbers on the left and sum of even row numbers on the right side under the sum column.

Here are all the observational notes regarding using the formula.

Notes:

  1. The formula only works with numbers.
  2. The two ranges provided in the formula must have the same number of rows or the formula returns error.
  3. Negation (--) char changes values, TRUEs or 1s to FALSEs or 0s and FALSEs or 0s to TRUEs or 1s .
  4. MOD function takes single input and single output (remainder) but we want an array of values for the input range. Negation (--) character helps it do it.
  5. SUMPRODUCT function returns the sum after taking individual products in the corresponding array.
  6. Operators like equals to ( = ), less than equal to ( <= ), greater than ( > ) or not equals to ( <> ) can be performed within a formula applied, with numbers only.

Hope this article about How to get the Sum of odd numbers or How to get the sum of even numbers? in Excel is explanatory. Find more articles on COUNTIF functions here. If you liked our blogs, share it with your fristarts on Facebook. And also you can follow us on Twitter and Facebook. We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write us at info@exceltip.com

Related Articles

How to use the SUMPRODUCT function in Excel: Returns the SUM after multiplication of values in multiple arrays in excel.

SUM if date is between : Returns the SUM of values between given dates or period in excel.

Sum if date is greater than given date: Returns the SUM of values after the given date or period in excel.

2 Ways to Sum by Month in Excel: Returns the SUM of values within a given specific month in excel.

How to Sum Multiple Columns with Condition: Returns the SUM of values across multiple columns having condition in excel.

Popular Articles

50 Excel Shortcut to Increase Your Productivity : Get faster at your task. These 50 shortcuts will make you work even faster on Excel.

How to use the VLOOKUP Function in Excel : This is one of the most used and popular functions of excel that is used to lookup value from different ranges and sheets. 

How to use the COUNTIF function in Excel : Count values with conditions using this amazing function. You don't need to filter your data to count specific values. Countif function is essential to prepare your dashboard.

How to Use SUMIF Function in Excel : This is another dashboard essential function. This helps you sum up values on specific conditions.

Leave a Reply

Your email address will not be published. Required fields are marked *

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.

Visit Us On TwitterVisit Us On FacebookVisit Us On Youtube