ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   adding odd numbers (https://www.excelbanter.com/excel-worksheet-functions/58341-adding-odd-numbers.html)

mike1448

adding odd numbers
 
How can I add only the odd numbers in a column of numbers?

Max

adding odd numbers
 
One way, assuming the col of numbers is within A1:A100

Try in say, B1:
=SUMPRODUCT(--(MOD(A1:A100,2)=1),A1:A100)

and for summing the even numbers,
just switch the "MOD(...)=1", to "MOD(...)=0", i.e.:
=SUMPRODUCT(--(MOD(A1:A100,2)=0),A1:A100)
--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--
"mike1448" wrote in message
...
How can I add only the odd numbers in a column of numbers




B. R.Ramachandran

adding odd numbers
 
Hi,

If your data are in the range A2:A101, in some other cell (e.g., B2) enter
the following formula: it will add all the odd numbers in the column.

=SUMPRODUCT((A2:A101)*(MOD(A2:A101,2)=1))

To add only even numbers, change the '1' at the end of the formula to '0')

Regards,
B. R. Ramachandran


"mike1448" wrote:

How can I add only the odd numbers in a column of numbers?



All times are GMT +1. The time now is 03:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com