Counts all cell containing even numbers in the range

T

Thomas

Hi Everyone.

I need some help in counting all cell with even numbers in a range.

I used the below formula for range A1 to Z1,

=SUMPRODUCT(N(MOD(A1:Z1,2)=0))

The above does not work as expected.

1. The problem is if the cell is empty or 0, Excel treat it as an even
number and add to the count. Therfore, if A1 to Z1 contains 0 or empty, the
result will be 26.

2. If even number is added to the cell, the result is still the same - 26
unless odd number are added. Expected result : Total numbers of cell
contains 0 or empty - toal numbers of cell containing odd number.

No problem is encounter when counting odd numbers using the forumla,
=SUMPRODUCT(N(MOD(A1:Z1,2)=1))

Any solutions?
 
B

Biff

Hi Thomas!

Here's an unelegant solution:

=SUM(IF(A1:Z1>0,IF(MOD(A1:Z1,2)=0,1,0)))

Entered as an array - CTRL+SHIFT+ENTER

Biff
 
T

Thomas

Thanks.

Hi Thomas!

Here's an unelegant solution:

=SUM(IF(A1:Z1>0,IF(MOD(A1:Z1,2)=0,1,0)))

Entered as an array - CTRL+SHIFT+ENTER

Biff
 
B

Biff

You're welcome

Biff
-----Original Message-----
Thanks.

Hi Thomas!

Here's an unelegant solution:

=SUM(IF(A1:Z1>0,IF(MOD(A1:Z1,2)=0,1,0)))

Entered as an array - CTRL+SHIFT+ENTER

Biff



.
 
R

Ron Rosenfeld

Hi Everyone.

I need some help in counting all cell with even numbers in a range.

I used the below formula for range A1 to Z1,

=SUMPRODUCT(N(MOD(A1:Z1,2)=0))

The above does not work as expected.

1. The problem is if the cell is empty or 0, Excel treat it as an even
number and add to the count. Therfore, if A1 to Z1 contains 0 or empty, the
result will be 26.

2. If even number is added to the cell, the result is still the same - 26
unless odd number are added. Expected result : Total numbers of cell
contains 0 or empty - toal numbers of cell containing odd number.

No problem is encounter when counting odd numbers using the forumla,
=SUMPRODUCT(N(MOD(A1:Z1,2)=1))

Any solutions?

=SUMPRODUCT((A1:Z1<>0)*(MOD(A1:Z1,2)=0))

should work assuming there are no TEXT entries in the range.






--ron
 

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

Top