Counting Cells with odd and/or even values

  • Thread starter Thread starter yungexec
  • Start date Start date
Y

yungexec

Lets say I have range A1:A5 containing values 1,2,3,4,5 respectively. I
would like to count how many of these cells are odd and place that value
in A6. The same for even numbers as well (in A7).

Any help would be appreciated.
 
Hi

One way
=SUMPRODUCT(--(MOD(A1:A5,2)=1))
For even numbers, change the 1 in the formula to 0
 
Shame that ISEVEN doesn't work <g>

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Hi Bob

Yes, I played with that for a while but could not get a solution, so had
to resort to your favourite<g>
 
Oh it would still be SUMPRODUCT, but if you could do

=SUMPRODUCT(--(ISEVEN(A1:A5)))

that is so much more self-descriptive than using MOD. Unfortunately, the
ISEVEN function seems incapable of processing an array of values, just as
WEEKNUM cannot. Must be something to do with being an ATP function, I wonder
if it works with 2007 (must try it).

You could use

=SUMPRODUCT(--(EVEN(A1:A5)=A1:A5))

but I am not sure that that is any better than MOD

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top