How can I Count # cells in specified range with value range?

Mike666

New Member
Joined
Oct 26, 2007
Messages
6
I'm trying to count the number of cells in a column less than a value but greater than 0.

I would have thought the function should look like:

=COUNTIF(C:C, <=21 & >0)

However the operators doesn't seem to be acceptable within this format. They are displayed as a textual output. I've also tried:

=COUNTIF(C:C, 1:21)

and also creating a named label for the acceptable range of values

=COUNTIF(C:C, SOON)

where soon is a table with values 1 through 21

I realise I could do this by specifying a list of COUNTIF functions with each of the individual desired values and returning the sum to my target cell but there's got to be a more elegant solution. What if the range was 40000? I'm out of ideas so I'd appreciate anybody who can help. It doesn't seem like a tough problem but I've no idea as to the solution.
 
Try:

=SUMPRODUCT(--(C1:C100>0),--(C1:C100<=21))

Don't use whole columns in SUMPRODUCT (C:C).

Regards
Jon
 
Upvote 0
Re: How can I Count # cells in specified range with value ra

I'm trying to count the number of cells in a column less than a value but greater than 0.

I would have thought the function should look like:

=COUNTIF(C:C, <=21 & >0)

However the operators doesn't seem to be acceptable within this format. They are displayed as a textual output. I've also tried:

=COUNTIF(C:C, 1:21)

and also creating a named label for the acceptable range of values

=COUNTIF(C:C, SOON)

where soon is a table with values 1 through 21

I realise I could do this by specifying a list of COUNTIF functions with each of the individual desired values and returning the sum to my target cell but there's got to be a more elegant solution. What if the range was 40000? I'm out of ideas so I'd appreciate anybody who can help. It doesn't seem like a tough problem but I've no idea as to the solution.

=COUNTIF(C:C,">0")-COUNTIF(C:C,">21")

With a range housing 1 to 21, which is named, say, List...

=SUMPRODUCT(COUNTIF(C:C,List))
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top