I have a list of integers in a column, and I would like to count how many odd numbers there are. I tried using COUNTIF(D1:D33,MOD(,2)=1) and similar variations, but none seem to work. The numbers are ascending as the rows increase, but there can be blank cells in the column. Help? If you can do it without using countif, that's fine too.
Last edited by nesthead98; 07-22-2009 at 12:04 PM. Reason: solved
I've moved this to the Excel Worksheet Function Forum.
Re: your question... you say Column but then your COUNTIF sample is looking only at one Row (4)... presuming you mean Row
=SUMPRODUCT(--(MOD(4:4,2)=1))
Note although you can use entire row references in Sumproduct formulae pre 2007 the same is not true of entire column references (A:A) ... best when using Sumproducts and/or Arrays of any sort to keep range sizes to a minimum.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
In line with your revision to your original post:
=SUMPRODUCT(--(MOD(D1:D33,2)=1))
Here a COUNTIF is not really viable given the requirement to "alter" the source values to a simple - is odd / is even equivalent... wherever manipulation of source data is required COUNTIF/SUMIF are invariably ruled out as viable alternatives.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Awesome thanks.![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks