• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Count specific values in a range

Wilco()

Member
I want to count a range (D12:NN12) in a sheet. In this row there can be values "L" or "XL".

I try to count these values by using countifs:

=COUNTIFS(D12:NN12;"XL";D12:NN12;"L")

But this gives me 0. I have thought of using Sumproduct, but cannot get that to work either.

How can I count the amount of cells containing these 2 values?
 
Hello,

The COUNTIFS is not the best in your case. Try this one: =SUM(COUNTIF(D12:NN12,"L"),COUNTIF(D12:NN12,"XL"))

Pierre
 
Wilco

Just so you know, your original formula wouldn't work because each criteria is additive

Using: =COUNTIFS(D12:NN12;"XL";D12:NN12;"L")
You are asking Excel which records in D12:NN12 match XL and which records in D12:NN12 match L

of course none match both criteria

You can use Countifs like
=COUNTIFS(D12:NN12;"L")+COUNTIFS(D12:NN12;"XL")

Most typically Countifs is used with multiple fields like
=Countifs(Field 1, Criteria 1, Field 2, Criteria 2, etc)

Where it is quite possible for a record to match both criteria at the same time and hence be counted.

You may want to have a read of:
http://chandoo.org/wp/2010/04/20/introduction-to-excel-sumifs-formula/
 
Back
Top