LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,358
Default Countif function for Even and Odd numbers

I guess the OP declaration of ...I would like to count a column that
consists of
even and odd numbers ... means nothing then.

Your argument, while technically correct, is unnecessary, as, per the OP,
the column will contain either even numbers or odd numbers.
--
** John C **


"Harlan Grove" wrote:

"T. Valko" wrote...
Try these:

Even numbers:

=SUMPRODUCT(--(MOD(A1:A10,2)=0))


This one's OK up to MOD's capabilities.

Odd numbers:

=SUMPRODUCT(--(MOD(A1:A10,2)0))

....

This isn't. Technically, numbers with fractional parts aren't either
even or odd. Even if 1.5 should be considered odd and 2.125 even, your
formula would treat both as odd. The correct formula for odd integers
is

=SUMPRODUCT(--(MOD(A1:A10,2)=1))

Then there's the problem that Excel's MOD function isn't reliable.
Among all applications currently supported which handle double
precision math, Excel's MOD function has a uniquely artificially
curtailed domain. Safer to use

=SUMPRODUCT(--(A1:A10-2*INT(A1:A10/2)=0)) for even integers

=SUMPRODUCT(--(A1:A10-2*INT(A1:A10/2)=1)) for odd integers



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
COUNTIF a cell value is between two numbers LAWNDALE Excel Worksheet Functions 3 August 15th 08 11:47 PM
countif colored numbers Mark Excel Worksheet Functions 2 May 22nd 08 09:12 AM
Embed a countif function in subtotal function? Stuck at work Excel Worksheet Functions 1 February 14th 06 03:19 AM
COUNTIF for range of numbers bimseun Excel Discussion (Misc queries) 3 January 24th 06 02:40 PM
Countif for numbers between x and y don Excel Worksheet Functions 4 May 5th 05 01:01 PM


All times are GMT +1. The time now is 10:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"