Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to count if a cell value falls between two numbers

8,970 views
Skip to first unread message

Glenn

unread,
Nov 3, 2009, 6:19:01 PM11/3/09
to
I tried to write a formula to count how often the value of a range of cells
falls between two numbers. for example in the chart below:

row value
1 25
2 27
3 36
4 37
5 42

I tried the formula =countif(a1:a5,and(>35,<40)) and my result was "0" when
it should be "2".

Can anyone help correct my formula?

thanks

glenn
--
Glenn

Tom Hutchins

unread,
Nov 3, 2009, 6:26:01 PM11/3/09
to
Try

=SUMPRODUCT(--(B1:B5>35),--(B1:B5<40))

Hope this helps,

Hutch

ryguy7272

unread,
Nov 3, 2009, 6:38:01 PM11/3/09
to
There are a few ways to to this:
=SUMPRODUCT((A1:A5>35)*(A1:A5<40))

=COUNTIF(A1:A5,">35")-COUNTIF(A1:A5,">40")

HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.

Ashish Mathur

unread,
Nov 3, 2009, 6:42:14 PM11/3/09
to
Hi,

=countif(A1:A5,">35")-countif(A1:A5,"<40")

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"Glenn" <Gl...@discussions.microsoft.com> wrote in message
news:E168B099-CA64-42BB...@microsoft.com...

Jacob Skaria

unread,
Nov 3, 2009, 9:58:04 PM11/3/09
to
Ashish, you meant to say >40...

Ryan, since the condition is <40 you need to have the second condition as >=40

=COUNTIF(A1:A5,">35")-COUNTIF(A1:A5,">=40")

Glenn, if you are using Excel 2007 you can try the below

=COUNTIFS(A1:A5,">35",A1:A5,"<40")

If this post helps click Yes
---------------
Jacob Skaria

0 new messages