# How to use Excel COUNTIFS and COUNTIF with multiple criteria

The tutorial explains how to use COUNTIFS and COUNTIF formulas with multiple criteria in Excel based on AND as well as OR logic. You will find a number of examples for different data types - numbers, dates, text, wildcard characters, non-blank cells and more.

Of all Excel functions, COUNTIFS and COUNTIF are probably most often mixed up because they look very much alike and both are purposed for counting cells based on the specified criteria.

The difference is that COUNTIF is designed for counting cells with a single condition in one range, whereas COUNTIFS can evaluate different criteria in the same or in different ranges. The aim of this tutorial is to demonstrate different approaches and help you choose the most efficient formula for each particular task.

## Excel COUNTIFS function - syntax and usage

The Excel COUNTIFS function counts cells across multiple ranges based on one or several conditions. The function is available in Excel 365, 2021, 2019, 2016, 2013, Excel 2010, and Excel 2007, so you can use the below examples in any Excel version.

### COUNTIFS syntax

The syntax of the COUNTIFS function is as follows:

COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2]…)
• criteria_range1 (required) - defines the first range to which the first condition (criteria1) shall be applied.
• criteria1 (required) - sets the condition in the form of a number, cell reference, text string, expression or another Excel function. The criteria defines which cells shall be counted and can be expressed as 10, "<=32", A6, "sweets".
• [criteria_range2, criteria2]… (optional) - these are additional ranges and their associated criteria. You can specify up to 127 range/criteria pairs in your formulas.

In fact, you don't have to remember the syntax of the COUNTIF function by heart. Microsoft Excel will display the function's arguments as soon as you start typing; the argument you are entering at the moment is highlighted in bold. ### Excel COUNTIFS - things to remember!

1. You can use the COUNTIFS function in Excel to count cells in a single range with a single condition as well as in multiple ranges with multiple conditions. If the latter, only those cells that meet all of the specified conditions are counted.
2. Each additional range must have the same number of rows and columns as the first range (criteria_range1 argument).
3. Both contiguous and non-contiguous ranges are allowed.
4. If the criteria is a reference to an empty cell, the COUNTIFS function treats it as a zero value (0).
5. You can use the wildcard characters in criteria - asterisk (*) and question mark (?). See this example for full details.

## How to use COUNTIFS and COUNTIF with multiple criteria in Excel

Below you will find a number of formula examples that demonstrate how to use the COUNTIFS and COUNTIF functions in Excel to evaluate multiple conditions.

### How to count cells with multiple criteria (AND logic)

This scenario is the easiest one, since the COUNTIFS function in Excel is designed to count only those cells for which all of the specified conditions are TRUE. We call it the AND logic, because Excel's AND function works this way.

#### Formula 1. COUNTIFS formula with multiple criteria

Suppose you have a product list like shown in the screenshot below. You want to get a count of items that are in stock (value in column B is greater than 0) but have not been sold yet (value is column C is equal to 0).

The task can be accomplished by using this formula:

`=COUNTIFS(B2:B7,">0", C2:C7,"=0")`

And the count is 2 ("Cherries" and "Lemons"): #### Formula 2. COUNTIFS formula with two criteria

When you want to count items with identical criteria, you still need to supply each criteria_range / criteria pair individually.

For example, here's the right formula to count items that have 0 both in column B and column C:

`=COUNTIFS(\$B\$2:\$B\$7,"=0", \$C\$2:\$C\$7,"=0")`

This COUNTIFS formula returns 1 because only "Grapes" have "0" value in both columns. Using a simpler formula with a single criteria_range like COUNTIFS(B2:C7,"=0") would yield a different result - the total count of cells in the range B2:C7 containing a zero (which is 4 in this example).

### How to count cells with multiple criteria (OR logic)

As you have seen in the above examples, counting cells that meet all of the specified criteria is easy because the COUNTIFS function is designed to work this way.

But what if you want to count cells for which at least one of the specified conditions is TRUE, i.e. based on the OR logic? Overall, there are two ways to do this - by adding up several COUNTIF formulas or using a SUM COUNTIFS formula with an array constant.

#### Formula 1. Add up two or more COUNTIF or COUNITFS formulas

In the table below, supposing you want to count orders with the "Cancelled" and "Pending" status. To have it doen, you can simply write 2 regular Countif formulas and add up the results:

`=COUNTIF(\$C\$2:\$C\$11,"Cancelled") + COUNTIF(\$C\$2:\$C\$11,"Pending")` In case each of the functions is supposed to evaluate more than one condition, use COUNTIFS instead of COUNTIF. For example, to get the count of "Cancelled" and "Pending" orders for "Apples" use this formula:

`=COUNTIFS(\$A\$2:\$A\$11, "Apples", \$C\$2:\$C\$11,"Cancelled") + COUNTIFS(\$A\$2:\$A\$11, "Apples", \$C\$2:\$C\$11,"Pending")` #### Formula 2. SUM COUNTIFS with an array constant

In situations when you have to evaluate a lot of criteria, the above approach is not the best way to go because your formula would grow too big in size. To perform the same calculations in a more compact formula, list all of your criteria in an array constant, and supply that array to the criteria argument of the COUNTIFS function. To get the total count, embed COUNTIFS inside the SUM function, like this:

SUM(COUNTIFS(range,{"criteria1","criteria2","criteria3",…}))

In our sample table, to count orders with the status "Cancelled" or "Pending" or "In transit", the formula would go as follows:

`=SUM(COUNTIFS(\$C\$2:\$C\$11, {"cancelled", "pending", "in transit"}))` In a similar manner, you can count cells based on two or more criteria_range / criteria pairs. For instance, to get the number of "Apples" orders that are "Cancelled" or "Pending" or "In transit", use this formula:

`=SUM(COUNTIFS(\$A\$2:\$A\$11,"apples",\$C\$2:\$C\$11,{"cancelled","pending","in transit"}))` You can find a few more ways to count cells with OR logic in this tutorial: Excel COUNTIF and COUNTIFS with OR conditions.

### How to count numbers between 2 specified numbers

By and large, COUNTIFS formulas for numbers fall into 2 categories - based on several conditions (explained in the above examples) and between the two values you specify. The latter can be accomplished in two ways - by using the COUNTIFS function or by subtracting one COUNTIF from another.

#### Formula 1. COUNTIFS to count cells between two numbers

To find out how many numbers between 5 and 10 (not including 5 and 10) are contained in cells C2 through C10, use this formula:

=COUNTIFS(C2:C10,">5", C2:C10,"<10") To include 5 and 10 in the count, use the "greater than or equal to" and "less than or equal to" operators:

=COUNTIFS(B2:B10,">=5", B2:B10,"<=10")

#### Formula 2. COUNTIF formulas to count numbers between X and Y

The same result can be achieved by subtracting one Countif formula from another. The first one counts how many numbers are greater than the lower bound value (5 in this example). The second formula returns the count of numbers that are greater than the upper bound value (10 in this case). The difference between the first and second number is the result you are looking for.

• =COUNTIF(C2:C10,">5")-COUNTIF(C2:C10,">=10") - counts how many numbers greater than 5 and less than 10 are in the range C2:C10. This formula will return the same count as shown in the screenshot above.
• =COUNTIF(C2:C10, ">=5")-COUNTIF(C2:C10, ">10") - the formula counts how many numbers between 5 and 10 are in the range C2:C10, including 5 and 10.

### How to use cell references in COUNTIFS formulas

When using logical operators such as ">", "<", "<=" or ">=" together with cell references in your Excel COUNTIFS formulas, remember to enclose the operator in "double quotes" and
add an ampersand (&) before a cell reference to construct a text string.

In a sample dataset below, let's count "Apples" orders with amount greater than \$200. With criteria_range1 in cells A2:A11 and criteria_range2 in B2:B11, you can use this formula:

`=COUNTIFS(\$A\$2:\$A\$11, "Apples", \$B\$2:\$B\$11, ">200")`

Or, you can input your criteria values in certain cells, say F1 and F2, and reference those cells in your formula:

`=COUNTIFS(\$A\$2:\$A\$11, \$F\$1, \$B\$2:\$B\$11, ">"&\$F\$2)`

Please notice the use of absolute cell references both in the criteria and criteria_range arguments, which prevents the formula from being broken when copied to other cells. ### How to use COUNTIFS with wildcard characters

In Excel COUNTIFS formulas, you can use the following wildcard characters:

• Question mark (?) - matches any single character, use it to count cells starting and/or ending with certain characters.
• Asterisk (*) - matches any sequence of characters, you use it to count cells containing a specified word or a character(s) as part of the cell's contents.

Tip. If you want to count cells with an actual question mark or asterisk, type a tilde (~) before an asterisk or question mark.

Now let's see how you can use a wildcard char in real-life COUNTIFS formulas in Excel. Suppose, you have a list of projects in column A. You wish to know how many projects are already assigned to someone, i.e. have any name in column B. And because we are learning how to use the COUNTIFS function with multiple criteria, let's add a second condition - the End Date in column D should also be set.

Here is the formula that works a treat:

`=COUNTIFS(B2:B10,"*",D2:D10,"<>"&""))`

Please note, you cannot use a wildcard character in the 2nd criteria because you have dates rather that text values in column D. That is why, you use the criteria that finds non-blank cells: "<>"&"" ### COUNTIFS and COUNTIF with multiple criteria for dates

The COUNTIFS and COUNTIF formulas you use for dates are very much similar to the above formulas for numbers.

#### Example 1. Count dates in a specific date range

To count the dates that fall in a certain date range, you can also use either a COUNTIFS formula with two criteria or a combination of two COUNTIF functions.

For example, the following formulas count the number of dates in cells C2 through C10 that fall between 1-Jun-2014 and 7-Jun-2014, inclusive:

`=COUNTIFS(C2:C9, ">=6/1/2014", C2:C9, "<=6/7/2014")`

`=COUNTIF(C2:C9, ">=6/1/2014") - COUNTIF(C2:C9, ">6/7/2014")` #### Example 2. Count dates with multiple conditions

In the same manner, you can use a COUNTIFS formula to count the number of dates in different columns that meet 2 or more conditions. For instance, the below formula will find out how many products were purchased after the 20th of May and delivered after the 1st of June:

`=COUNTIFS(C2:C9, ">5/1/2014", D2:D9, ">6/7/2014")` #### Example 3. Count dates with multiple conditions based on the current date

You can use Excel's TODAY() function in combination with COUNTIF to count dates based on the current date.

For example, the following COUNTIF formula with two ranges and two criteria will tell you how many products have already been purchased but not delivered yet.

`=COUNTIFS(C2:C9, "<"&TODAY(), D2:D9, ">"&TODAY())` This formula allows for many possible variations. For instance, you can tweak it to count how many products were purchased more than a week ago and are not delivered yet:

`=COUNTIFS(C2:C9, "<="&TODAY()-7, D2:D9, ">"&TODAY())`

This is how you count cells with multiple criteria in Excel. I hope you will find these examples helpful. Anyway, I thank you for reading and hope to see you on our blog next week!

## You may also be interested in

1. I have a sheet I am working on with dropdowns. I have fir example column E3:E63 has a dropdown box of new, used, pending or purchase. I need a formula to count say the "new" as 1, but in column F3:F63 I have a dropdown with employee names, so if a persons name is selected I need it subtract .5, if no name is selected or "no" then it can stay as 1. Not to add in addition to, but to just remain 1. If that makes sense?
To give you the scenario, I sell cars for a living. So, when I track my sold units I have a dropdown that tells me if it was a new car, used car, pending or a purchase. In the next column, (F) if I had to split the sale with an employee and I select their name I need it to subtract .5 from the new car or used car etc. I can count it as a whole number using the =Countif(E3:E63, "new") and it tallies a 1 in the "new units sold" section, but if it happens to be a split with another employee in column F3:F63 I need it to subtract .5. Is this possible, and if so, what is the formula? I have been trying to figure this out for 2 months and cannot get it!

• I'm sure others will provide a better answer but what I would do is create a formula in column G that that basically says that if F is not blank (meaning it includes a sales person's name with whom you'll split the sale with) then return .5, otherwise 1. =IF(F3="",1,0.5) copy this down to F63. then you can just sum those numbers together to get you the total units sold including split sales.

• Hi! The COUNTIFS function can be used to find the sum of multiple conditions. For example,

=SUMIF(F2:F10,"",E2:E10)+SUMIF(F2:F10,"no",E2:E10)+SUMIFS(E2:E10,F2:F10,"<>",F2:F10,"<>no")*0.5

You can also use the SUMPRODUCT function to find the sum of multiple criteria.

=SUMPRODUCT(E2:E10,0.5+0.5*(ISBLANK(F2:F10)+(F2:F10="no")))

2. In the tutorial above, there is an example that counts orders with the status "Cancelled" or "Pending" or "In transit". The provided formula is:

=SUM(COUNTIFS(\$C\$2:\$C\$11, {"cancelled", "pending", "in transit"}))

However, I’m interested in having the "cancelled", "pending", "in transit" portion of this formula contain a cell reference to this text. Something like:

=SUM(COUNTIFS(\$C\$2:\$C\$11, {\$D\$2})) where cell D2 contains "cancelled", "pending", "in transit".

Any suggestions on how to get it to work?

• Hi! You can write the conditions in three separate cells and use a COUNTIFS formula like this:

=SUM(COUNTIFS(\$C\$2:\$C\$11, D1:D3))

If you write all the conditions in one cell and separate them with spaces, use the TEXTSPLIT function to split the criteria:

=SUM(COUNTIFS(\$C\$2:\$C\$11, TEXTSPLIT(D1,," ")))

• Alexander, thank you so much. The TEXTSPLIT function was exactly what I needed. Definitely keeping that one in my back pocket for future use. Have a great weekend!

• One last question. In the example above the TEXTSPLIT worked great. How could I alter your suggestion to count excluding those three text items? I was thinking this might work but apparently I was wrong.

=SUM(COUNTIFS(\$C\$2:\$C\$11, ""&TEXTSPLIT(D1,",")))

• Thank you. I was offline for the last 10 days but will have a look at this later today. Appreciate your help :-)

3. Hello, I am trying to count how many colours are in a row of data cells e.g. Red, Green, Green, Yellow would be 3 colours. When I use SUM(COUNTIFS variables it says 4 because it is adding all colours. Is there a way to count only how many types of colours there are?

• Hi! COUNTIFS formula counts the number of all values by condition, including duplicates. To count only unique values, try using these guidelines: How to count unique values in Excel an easy way. I hope I answered your question. If something is still unclear, please feel free to ask.

• Thank you. I have tried a few of those formulas and can't figure it out.

Artem A Set1A Set1A Set1B Set1B Set1C Ditties Set1C

I need it to count how many times it says Set1A, Set1B, Set1C and Ditties in this example above. Because each row needs to be calculated differently as they are different start points, I am struggling to do it per row and not across the whole page of data like the examples show.

• Hi! As far as I can see from your second comment, your task is now different from the original one. You are asking a very different question from earlier. To count "how many times it says Set1A", use COUNTIF formula. For example:

=COUNTIF(\$A\$2:\$L\$2,C2)

If this is again not what you need, give an example of source data and write the desired result.

4. Hi,

I am wanting to find the sum of all cells which have a specific value in the same row.

I am currently logging teaching hours in a sheet and using a drop down in column D to select which class I am teaching (class A, class B, class C), then the amount of hours (1.5, 3, 4.5) in column G. Is there a way to add only the cells next to a specific class? So I can see a total number of hours for each specific class?

Thanks

• That's perfect, thank you :)

5. I'm trying to do a countifs with multiple text criteria, to breakdown how many sales were done by an individual from a particular lead source

As an example
John doe
how many were organic
how many were self generated

Jane doe
how many were organic
how many were self generated

• Hi! I hope you have studied the recommendations in the tutorial above. It contains answers to your question. If this does not help, explain the problem in detail.

6. I'm trying to have a formula that counts a student when two conditions "English" and "Graduated" are true, but I keep getting an error. I am trying to pull information from another sheet. Below is the formula I've been trying to use:

• Hi! The COUNTIFS function can only correctly calculate values for a condition on one sheet in one Excel spreadsheet. Please read the above article carefully.

7. I need to write a fomula that counts the UPC codes that were used in Las Vegas. There is a mixture of blanks and with letters. Here is a similar example:

Location UPC Codes
Las Vegas 981
Los Angeles 8989
Tokyo 9867
Las Vegas 8989
Los Angeles 8989
Tokyo
New York 65464
Miami Pi757
Las Vegas
Los Angeles 8989
Tokyo 2165
New York
Miami 235
Las Vegas 8989
Los Angeles G192
Tokyo Pi757
New York 8989
Miami 8989

• Hi! Please check out this article to learn how to count unique values in Excel: with criteria, ignoring blanks.
Try to use this formula:

=IFERROR(ROWS(UNIQUE(FILTER(B2:B20,A2:A20="Las Vegas"))), 0)

8. I need to identify the presence of an element in at least one column, in columns that are separated from each other, but I need to count it just once (even if it is in several columns).
For example, in column A I have attendance on day X; in column D I have the attendance for day Y and in column H I have the attendance for day Z. Each day is marked "Yes" or "No".
I need to count the people who attended, regardless of whether they went 1, 2 or 3 times. When using the countifs function, if the person was not there on a day, it doesn't count them. On the other hand, if I combine the countifs function and add what is derived from the Or function, then it counts it 1, 2, or 3 instead of 1. Is there a way to do it?

9. DATE SALESMAN PRODUCTION HORECA
01-Oct-23 NEERAJ PARIHAR CLOSED
01-Oct-23 NEERAJ PARIHAR CLOSED CLOSED
06-Oct-23 RAFIQ SHEIKH CLOSED CLOSED
10-Oct-23 NEERAJ PARIHAR CLOSED CLOSED
14-Oct-23 NEERAJ PARIHAR CLOSED CLOSED
15-Oct-23 NEERAJ PARIHAR CLOSED CLOSED

Need to know that which sales man has generated how many leads in production and HORECA on daily basis. Required daywise report

• Hi! I can't guess what result you wanted to get. Please provide me with an example of the expected result.

10. Hi, i have a question about a seemingly simple function but i cannot get it figured out.

So this is the formula i have

=COUNTIFS(I:I,"",D:D,"DEPO",B:B,"2024FA")+COUNTIFS(J:J,"86",D:D,"DEPO",B:B,"2024FA")

Now, the context is that i need to count a person whether they have either any value in Column I, or a value of 86 in Column J as well as the criteria for columns D and B staying the same. People CAN have both values present. The way the formula is written now, if someone has both values present, they are counted twice.

Am i missing something? I thought of using an OR function, but i cannot get that to work. Anyone have any insight into this?

Thank you!

• Hello! Subtract the number of people who have both values present. Try the formula:

=COUNTIFS(I:I,"",D:D,"DEPO",B:B,"2024FA")+COUNTIFS(J:J,"86",D:D,"DEPO",B:B,"2024FA") - COUNTIFS(I:I,"",J:J,"86",D:D,"DEPO",B:B,"2024FA")

11. Hi! I'm trying to count a range of cells across a large array; *if* they match the criteria in a single column,
so, my first through was; It should be as simple as

=COUNTIF(B3:B123, "A Shift", F3:HH123, "Assigned"),

now; if i'm understanding correctly; the the vertical range must be the same size;
Is failing because the horizontal range is larger?

If so; what's the solution to simply find

if x=a in a single vertical column, count how many occurrences on the horizontal =b

I've tried

=IF(B3:B123=A, COUNTIF(F3:HH123, "Assigned"),0) and that wants to spill to nearby cells;

What am I missing here?

• Hi! If I understand your task correctly, to count the number of values across multiple criteria, try using the SUMPRODUCT function. Here is an example formula:

=SUMPRODUCT((B3:B20="A Shift")*(F3:M20="Assigned"))

• Thanks for the speedy reply;
Unfortunately that example is returning 0

For what i'm trying to do, I have Column B which is just "A", "B", and "C" about 20 times each as we go down the rows from 3 to 123;

Then I have a matrix going across all the way from Column F to Column HH,

Some of the cells have dates in to indicate when a task completed; and some contain just the word "Assigned";

I'd like to count how many occurances of "Assigned" appear across the range where column B="A", then once that's working follow on for rows where Column B="B" and where Column B="C"

I originally used
=COUNTIFS('Primary Matrix'!F3:T30,"*Assigned*") to count the rows where Column B="A"

but this would mean that someone will have to manually adjust the formula whenever a new person is added to the range where B="A"

So rather i'd like to create a formula that will sum all occurrences of "Assigned" between Columns F and HH; only IF column B="A"

So i've tried your example like this, and I can see how it should work;

=SUMPRODUCT((B3:B123="A")*(F3:HH123="*Assigned*"))

But it returned 0 across a range that does contain multiple occurences of "Assigned", and I feel like i'm missing something obvious; but I can't work out what.

• Hi! The formula I sent to you was created based on the description you provided in your first request. However, as far as I can see from your second comment, your task is now different from the original one.
To learn how to find a partial text match, please read: How to find substring in Excel.
For example:

(ISNUMBER(SEARCH("Assigned",F3:HH123)))

• Hi,

I'll give that a go;

Apologies if it was unclear; the task has always been: count number of "*Assigned*" in a range; only where column B (outside of that range)="A*", and ignore other instances (within the range) of "*Assigned*"

• So, I've found a workaround;

I wanted to avoid adding any additional columns to the page with the data;

but by doing a single column with just

=COUNTIF(F3:HC3,"*Assigned*")

after the final data column; then all I had to do was (on the page I wanted to display the data)

=SUMIF('Primary Matrix'!B:B,"A*",'Primary Matrix'!HF:HF)

and likewise for B, and C.

that's solved it; not how I wanted to solve it; but it unarguably works now.

• *A single column, with that COUNTIF repeated for each row of data.

• Hi! If I understand correctly, use the FILTER function to get the range to count the "Assigned" values.

=SUMPRODUCT(--(FILTER(F3:M120,B3:B120="A")="Assigned"))

12. =COUNTIFS('Section 2'!\$AC:\$AC,"Pending",'Section 2'!\$AA:\$AA,">12 months")

I am trying the above formula to get the number of cases pending beyond 12 months, as per my data sheet the result of this formula should be 0. however, the formula is returning a value i.e. 1 in first instance & 2 in second instance.

When I removed the > sign, I got the desired result. Also, when I tried adding >12 months in my data sheet as a dummy value to test the formula, it did not return the correct number. why is that so?

• Hi! I can't check your formula because I don't have your data. However, your formula counts the number of text values, not dates. I recommend reading this guide: COUNTIF formulas for dates.

13. I am trying to incorporate the today function into my countifs formula. I have a column that reflects the date of activity but I can't seem to get it right.

The above formula is for my grand total report, but I need to show daily totals for cob that day on a separate sheet using the same information.

• Hi! Create a column with dates on a separate sheet. Then add a condition for the date to the COUNTIFS formula. For example:

D - column with dates.
You can get a report without formulas, using a pivot table with grouping by days. Read more: How to make and use Pivot Table in Excel.

14. I appreciate a lot to the information provided above. We are learning. However, I am still not clear on something I dont know which formula works best for the following example.

A B C
Month Dept Service Requested

1 Jan-23 Sales 0001
2 Jan-23 Sales 0001
3 Jan-23 Sales 0001
4 Jan-23 Operations 0001
5 Jan-23 Accounts 0002
6 Jan-23 Operations 0002
7 Jan-23 Accounts 0002
9 Feb-23 Accounts 0004
10 Feb-23 Sales 0004
11 Mar-23 Accounts 0005
12 Mar-23 Operations 0006
13 Mar-23 Sales 0007
14 Mar-23 Operations 0008

I want to count "how many service types were requested by each department per month". This means the formula has to count the similar service type once for same dept in the same month right.

15. I am using this formula and it is generating an incorrect value. =COUNTIFS('Tray Audit Log'!D:D, "Y",'Tray Audit Log'!B:B,">6/1/2023") - COUNTIFS('Tray Audit Log'!B:B,"<6/30/2023"). The data is counting 641 when there are actually 194 yes in the month of June.

I am trying to count the total y(yes) from one column and the MONTH from another column all information on a different tab. I can send the data via email I cannot attach it to this chat.

• Hi! If you want to calculate June data, use the dates of May 31 and July 1 in your formula.

16. I want to compare multiple dates for Planning dates vs. Actual dates; it seems that in planning dates there are several activities inclusion same with actual dates. I need to compare it 1 by 1 activity date and the true values will determine the condition of green, amber and red.

• Hi! Please clarify your specific problem or provide additional information to understand what you need. Give an example of the source data and the expected result.

17. Any way please to get the function criteria at countifs from a cell with multiple values into a criteria like {"A,", "B", "C") automatically?
A B D E
Item1 London PART DEPOT
Item1 London Item1 Frankfurt
Item2 London Item2 Hong Kong
Item1 Heathrow Item1 London
Item2 Manchester Item1 London, Manchester
Item1 Sandwell Item2 London, Manchester, Glasgow
Item1 Glasgow
Item2 Glasgow
Item3 Frankfurt

For example I need a =sum(countifs(A:A,D6,B:B, {"London", "Manchester","Glasgow"}) next to E6.
E6 is London, Manchester, Glasgow separated by comma.
any quick way to write the function so I can reference this cell but in a way it turns into {"London", "Manchester","Glasgow"} within the function instead of me typing it out?

• Unfortunately, the COUNTIFS function does not work with array formulas. You can write an array of values directly in a formula, but you cannot pass an array of values to a COUNTIFS formula using another function.

18. Can we use countifs in MS Excel with in different online sheets...

19. Hello,

I have tried using one of your formulas but I might have an incorrect understanding of it.

I am trying to count multiple criteria (frequency of the word "CVD" tagged to "Antipolo DC")

I try to use this formula =COUNTIFS(N3:N2028,"Antipolo DC",Y3:Y1048576,"CVD") but the results show #Value!

May I kindly check what I am possibly doing wrong?

Please note that Antipolo DC is a location (there are 20 other locations in the list) and CVD is an option (there are 5 other options in the list)

• Hi! I have said many times on this blog that the sizes of all ranges (that is, the number of rows and columns) in the COUNTIFS and SUMIFS functions should be the same.

20. Hi,
I am wanting to know if there is a formula on excel that would give me employees working at a given period per day. For example - there is a total of 20 people working at the facility but they all start and finish at different times. I want to know how many people are working from 9am to 10am etc etc. hope this makes sense.

Thanks

• Hi! The answer to your question can be found in this paragraph of the article above: How to count numbers between 2 specified numbers. Count the number of values greater than the start time and less than the end time. I can't offer you a formula as I don't have your data.

21. Hello, I cannot figure out what formula to use for this problem. Referring to the data set below... Let's say column A is an employee number and I need to count all of the Ns for that employee, how would I write that formula? The other issue is the number of rows for each employee will not always be the same. For example, employee 1260 may have 7 rows, employee 1266 may have 12 rows, employee 1279 may have 15 rows.... so the range will always be different. The next issue is that the spreadsheet has 115311 rows so I cannot individualize each formula with the employee number or range. The formula would need to find each unique employee, establish the range and then count the number of Ns or Ps or whatever within that range. I was trying the =countifs formula trying to get it to use whatever number is in A1 as Criteria1, then giving the next range and asking it to count the Ns. =COUNTIFS(\$A2:\$A115311,"=A2", C2:I27,"N") ..... this formula did not work. LOL

Not picky if it is displayed on a separate sheet. If its easier, it could put the report on a separate sheet which would list the unique employee number followed by how many Ns, Ps, 7s, As, etc.

1260 4/2/2023 N N N N 7 N N
1260 4/9/2023 N 7 N P N N N
1260 4/16/2023 N N N N N A Q
1260 4/23/2023 A P N N N A N
1260 4/30/2023 7 N N A A A Q
1266 5/7/2023 N N A N N N N
1266 5/14/2023 N N A A P 7 N
1266 5/21/2023 N P N A A A Q
1266 5/28/2023 N N N N N N N
1266 6/4/2023 N N N A A Q N

• Hi! Read the instructions above carefully. Also note that all ranges in the COUNTIFS function must have the same size, i.e. the same number of rows and columns.

22. A need Help for All Apples count and only show Delivered Percentage
if i use this code "=COUNTIFS(\$A\$2:\$A\$11, "Apples", \$C\$2:\$C\$11,"Delivered")" its show (Apples Delivered 3) . if i had total 10 Apples and Delivered only 3 it will show Apples Delivered 30 %.

• Hi! You can learn how to correctly calculate the percentage in this article: How to calculate percentage in Excel.
Please check the formula below, it should work for you:

=COUNTIFS(\$A\$2:\$A\$11, "Apples", \$C\$2:\$C\$11,"Delivered")/COUNTIFS(\$A\$2:\$A\$11, "Apples")

23. Thanks for the information.

I would like to count the number of unique value based on a set of "OR" & "AND" criteria.

Given the following,
A 3366 1 0
A 3329 1 1
B 2282 1 1
B 2282 1 1
B 2282 0 1
B 3409 1 0

To count the number of unique value of column B with following criteria: column A = "B" AND column C = 1, I could get the answer with
={SUM(IF((A1:A6="B")*(C1:C6=1),1/COUNTIFS(A1:A6,"B",C1:C6,1,B1:B6,B1:B6)))}

How to add an "OR" condition to the criteria for this?
say I would like to count the number of unique value of column B with the following criteria: column A = "B" AND ((column C = 1) or (column D = 1))
of course apart from generating a new column E to do the logic.

Thank you.

24. I'm wondering if it's possible to count selected cell with conditional formatting with a date. counting the following
A5 + A8 +A10

each cell draws information using lookup formulas and conditional formatting

A5 = date (01/05/24)
A8 = date (26/09/22)
A10 = Txt (not trained)

= number of cells greater then TODAY()
this example = 1

25. Hello all, this is a fantastic site, I've learned so much, can't tell you! OK, I can't seem to figure out how to do this, it seems simple, I must be missing something.
I want to count cells that have certain text strings within the cell that has a whole bunch of words in it. So let's say I've got a whole bunch of cells that contain sentences like this:

Mary went to the store to get apples
James went to the store to get oranges
James went to the store to get apples

etc., etc.

I want a formula that will count how many cells contain both "Mary" and "apples". I've tried the following, but they don't work:

=COUNTIFS(\$A\$1:\$A\$10,*Mary*,\$A\$1:\$A\$10,*apples*)
=COUNTIFS(\$A\$1:\$A\$10,"Mary",\$A\$1:\$A\$10,"apples")

Do I need to use the AND statement? Or maybe there's an issue searching for the words in the cell?

Thanks all.

Tom

• Add quotation marks to the text string. Try this formula:

=COUNTIFS(\$A\$1:\$A\$10,"*Mary*",\$A\$1:\$A\$10,"*apples*")

Please have a look at this guide: How to find substring in Excel. For example:

=SUMPRODUCT(ISNUMBER(SEARCH("apple",A1:A10)) * ISNUMBER(SEARCH("mary",A1:A10)))

• This is perfect, thank you so much for replying, much appreciated!

Tom

26. This formula counts 5 occurrences of 'X' or more than 5 'X' as 1 and it also does not count lower case 'x' and it is good. But, how can I modify this so that it will not count interrupted appearance of 'X' in a row but only unbroken 5 'X' or XXXXX? Broken and interrupted is like this ( XXXX X, XXX__XX and others) =SUM(IF(MMULT(--(EXACT(F8:AK39, "X")), TRANSPOSE(COLUMN(F8:AK39)^0)) >= 5, 1, 0))

• Hi! Your formula is not working for me. If I understand the problem correctly, try this formula:

=SUM(--ISNUMBER(FIND("XXXXX",F8:AK39)))

27. =COUNTIFS('Sheet1'!\$C\$2:\$C\$29586,">="&'Safety Event'!C\$1,'Sheet1'!\$E\$2:\$E\$29586,"=Near Miss*",'Sheet1'!\$BP\$2:\$BP\$29586,"SSS 05:00*",'Sheet1'!\$C\$2:\$C\$29586,"<="&'Safety Event'!C\$2)

Can you add more on top of "SSS 05:00*"? I have to add more 6 items to count. or can we just slot a table range instead?

To count lets say from July 2, 2023 (C1) to July 8, 2023 (C2) to count ---- if Column E2:E9586 is showing a text Near Miss* miss and column BP is showing the text SSS 05:00* ( I want to add more shift aside from SSS 05:00)

28. Not really a comment although I loved the info and was able to use it in a spreadsheet I keep active with a group of 9 golfers and therein lies my question...
I have been trying for over a month now to auto copy data in a column of cells to another column, next to it. The data in the first column changes frequently, sometimes 4-5 times a week. What I need to do is copy the data in the first column into the second column before the first column is overwritten by the data entered on any given day. It's a small table that tracks a golfers drives (distance on each hole). I am trying to keep track of their last 5 rounds but can't figure out how to shift everything over 1 column before the new data overwrites in the first column. HELP!!!!

29. Hi, Needed help using the COUNTIFS formula with conditions, essentially I want to be able to count the number of times any initials from the data below features in the data set below, based on the region, month and if it is H&S/Commercial. I.e I want to be able to count the number of times text appears in May for H&S, for the North Planned region and similarly the number of times text appears in May-23 for Commercial. The list of names that will appear is roughly 11-12 (I can use a wildcard for the total times text appears for that particular month but can't get it to work when trying to get it for just H&S/Commercial:

May-23
Week Commencing 01-May-23 08-May-23 15-May-23 22-May-23 29-May-23

H&S Commercial H&S Commercial H&S Commercial H&S Commercial H&S Commercial

Region Contract

North Planned Guinness - PM LH
Wrexham - Voids SR
Wakefield - External Works PCSA Stage
Sheffield City Council - Sheffield Adaptations
Leeds CC - Back to Backs
St Leger - Towers
Oldham - PFI
St Leger - New Capital Framework
Kirklees Lot 1
Sheffield High Rise
FCHO
Guinness SHDF
Incommunities
Guinness SHDF Wave 2
Places for People
Together Housing
SCC Acquisitions

• Hi! Unfortunately, based on your description, I can't understand what you want to count. To calculate values for multiple criteria, you can use the COUNTIFS function as described in the article above. You can also use the SUMPRODUCT function and these instructions: Conditionally count / sum / average cells with multiple criteria.
Or explain the problem in more detail.

30. Last attempt at this.

Sorry for the spam, but this message system is posting stuff I'm not typing and not posting stuff I am.

I have a datasheet and then a stats sheet, I'm trying to populate the Stats sheet automatically from data entered into the data sheets based on a monthly period.

Jan, Feb, Mar etc.

My formula is a COUNTIFs which first checks outcome column for the word "Positive NR" then it checks the Date Column for dates ">=" and "="&Data!A1,'[SS Stats 2023.xlsx]2023'!\$A:\$A,"<="&Data!A2)

• Yeah its done it again. Cannot send you my formula, but believe me the ones which are working and the ones which doesn't are identical other than the "Positive" and "Positive NR", so cannot work it out.

• Hi! Study carefully the last paragraph in the article above. Here is an example of the formula:

=COUNTIFS(\$I:\$I,"Positive",\$A:\$A,">="&A1) - COUNTIFS(\$I:\$I,"Positive", \$A:\$A,">="&A2)

31. Hi,

I'm trying to create a spreadsheet for work which will calculate the statistics for each month throughout the year based on another spreadsheet we use to hold all the data.

So we have a column with received date, a column with District and another column with an outcome.

What I'm trying to do with limited success is Check "Date Received" column for any dates within each month, then check another column with those dates which matches 1 of 5 words added to that column.

Example 1:

Column A - Check for all Cells with Dates between and including 01/01/2023 to 31/01/2023.
Column C - Check for all Cells with Text containing exactly "POSITIVE".

Below my Formula (I have a separate datasheet hidden on the workbook which contains all my month dates).

=COUNTIFS('[SS Stats 2023.xlsx]2023'!\$I:\$I,"Positive",'[SS Stats 2023.xlsx]2023'!\$A:\$A,">="&Data!A1,'[SS Stats 2023.xlsx]2023'!\$A:\$A,"="&Data!A1,'[SS Stats 2023.xlsx]2023'!\$A:\$A,"="&Data!A23,'[SS Stats 2023.xlsx]2023'!\$A:\$A,"="&Data!A1,'[SS Stats 2023.xlsx]2023'!\$A:\$A,"<="&Data!A2)

Any assistance on this would be great, as its driving me up the wall right now, it should work and I cant see why it doesn't :(

• Welp same issue again.

=COUNTIFS('[SS Stats 2023.xlsx]2023'!\$I:\$I,"Positive",'[SS Stats 2023.xlsx]2023'!\$A:\$A,">="&Data!A1,'[SS Stats 2023.xlsx]2023'!\$A:\$A,"="&Data!A1,'[SS Stats 2023.xlsx]2023'!\$A:\$A,"="&Data!A23,'[SS Stats 2023.xlsx]2023'!\$A:\$A,"="&Data!A1,'[SS Stats 2023.xlsx]2023'!\$A:\$A,"<="&Data!A2)

• Ok I give up, it wont let me post my message or any variation of it, and all it does is make it look like my formula is massively wrong when the above formula has some "=" statements inbetween the ">=" and "<=" statements. I dont know how to fix it.

• Hi! Pay attention to the last paragraph of the article above: Count dates with multiple criteria. Count the values where the dates are greater than the start date, subtract the values where the dates are greater than the end date.

32. I'm trying to do =COUNTIF(B:B, C:C-9) and it's not working.
How do i get around this?

• Hi! I don't really understand what you want to calculate. But the arguments to the COUNTIF and COUNTIFS functions cannot be formulas. They can only be values or cell references. Read the article above carefully.

33. Hi
I am trying to write a count if formula to count between two dollar figures...which appear

C4-DB4 is a run of varying \$ amounts
DE4 is the max value (FORMULA)
DD4 is 10% less than max value (FORMULA)

=COUNTIFS(C4:DB4,">=DE4", C4:DB4,"<=DD4")

The above forumla wont count the number of \$ values between max and 10% discount. Please help!

34. Hello,

I'm trying to write a formula that uses data from different cells based on where today's date falls within a date range. This is what I have:

=IF((AND(TODAY()>=DATE(2023,6,1),TODAY()0,CPEP!A9),"")

Obviously, this isn't working. Any ideas?

• =IF((AND(TODAY()>=DATE(2023,6,1),TODAY()0,CPEP!A9),"")

• I don't think it is showing the full formula.

If this is not what you need, explain the problem in more detail.

35. Thanks for the information it helped me a lot, I Tried to combine cells as a cross criteria search.

=COUNTIFS(D\$1:D\$94,D101,J\$1:J\$94,"X")

The " X " Mark means was punched on a different Day (Monday,Tuesday, etc) for Example if Cell J1 has mark and Value D101 is in the range criteria, it will count, but only if both met the criteria ( values and X mark).

36. Hi,

Is it possible to tag a progress with each cell containing different data?

The information will be tagged as "complete" if either "email", "mobile no.", or "address" is provided. It does not necessarily need to have all the information (at least one of the 3 should be fine)

Thank you!

Steve

37. Hi Alex... Im suffering here...

I need to count how many F there are in multiple colums

If I count the "F" in one column, works great:
=COUNTIFS(A:A,"JUNE",B:B,"F")

but what i really need is to count the "F" in multiple columns:
=COUNTIFS(A:A;"JUNE",B:K,"F")

and it doesnt work, what am I doing wrong? is there a way I can do this?

any help, will be appreciated.

thank you! claudia

• Hello! All the ranges you use in the COUNTIFS function must be the same size. That's why your formula doesn't work. I recommend reading this article: Excel COUNTIF and COUNTIFS with OR logic.
Here's an example of the formula:

=COUNTIFS(A:A,"JUNE",B:B,"F") + COUNTIFS(A:A,"JUNE",C:C,"F") + COUNTIFS(A:A,"JUNE",D:D,"F")

• oh... got it..that is what i was afraid of... i didnt want to make the formula too long...
thank you so much, let me check that part of the article again!

thank you, Alex!!

38. I have list of trainings in rows and completion status in columns against the resource. How can I use COUNTIF formula to see number of resources who have completed / in progress for each training? Kindly help

• If the formulas and examples in the article above don't work for you, give an example of the source data and the desired result.

39. is something like this possible?

IF(COUNTIFS(R2,"value1*",S2,"status1"),"aaa","bbb"),IF(COUNTIF(R6,"value2*"),"aaa","bbb")

or

IF(COUNTIFS(R2,"value1*" OR "value2",S2,"status1" OR "status2" or "status3"),"aaa","bbb")

Thanks

40. Why do I get an error message with th3 following excel formula?
=IF( COUNT(B90:C90)=2,MOD(C90-B90,1)*24,0)
The error message only shows up after the date is added in Column A. Start time is column B and end time is column C.
Thank you!

• Hi! I can't check your formula because I don't have your data. An error is possible if the cells contain text but not time. Also, I can't guess which error message you see. Note that there is no reference to column A in the formula.

41. Hello Dear Team,

I have an question that is possible to count three or four things with a single formula against every value as shown in the data:-

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 P H A L s/l
P P P P P H P P P P P P H P L L P P P H P a a P P P H S/L S/L P P 21 4 2 2 2

• Hi! Unfortunately, this information is not enough to understand what you need.

• i want to count total no. of P,H,A,L and s/l with a single formula from the given data.

• Hi! If I understand the question correctly, the formula might look something like this:

=SUM(COUNTIF(A1:T1,{"P","H"}))

• Thanks a lot Sir,
Actually I want to count all P in column "P"
Count of all H in column H at the end and all L,S/l in their respective column simultaneously with a single formula
e,g: total P=24
Total H=5
Total L-3
Total S/l=2

• Hi! If I understand your task correctly, use a separate COUNTIF function for each column. For example,

=COUNTIF(H1:H100,"H")+COUNTIF(P1:P100,"P")

42. Thank you so much, I coundn't remember how to use more then one formula on the same cell and somehow this was the only post that used the + to help me count more then one different word into the same cell.

43. Hi alexander,
I have two column of products and I need to find out if a certain brand of a retailer is offered at the other retailer in the other column. Offered by 'retailer ' 'yes' = 1, if not offered then = 0
is it possible to find out if a brand is offered in the other column without using a specific wildcard? otherwise the wildcard will have to be changed per product and this would not be possible.

44. Hi, I got small problem.

I cannot find a way to formulate a suitable formula. I hope you can help me.

I have to count how many of the people who worked on the DON project were between the 16 and 24 years, male, from China. I need to include all of this as of 12/31/2015. Most important is fact that some of people quit work before that date so I need to exclude them.
Start of contract is between C3 to C100, end of contract D3 to D100, Birth date E3 to E100, country of residence is F3 to F100, project name is G3 to G100, gender I3 to I100.

I made it as per the formula below, but I don't know how to count the age bracket correctly (between 16 and 24 years) and eliminate people who finished work before this date (12/31/2015).
=COUNTIFS(C3:C100, "<=12/31/2015", F3:F100, "China", G3:G100, "DON", I3:I100, "M", )

TIA John

• Hello!
The COUNTIFS function cannot use other functions or formulas as arguments. Therefore, I recommend using the SUMPRODUCT function.

=SUMPRODUCT(--(C3:C100<=DATE(2015,12,31)), --(F3:F100="China"), --(G3:G100="DON"),--(I3:I100="M"), --(DATEDIF(E3:E100,TODAY(),"y")>=16), --(DATEDIF(E3:E100,TODAY(),"y")<=24))

You can also find useful information in this article: How to calculate age in Excel.

45. Hi Alexander,
Im a new user, how do I express eg that the Yes must relate to the occurrences of LS rather than any Yes that appears in the column.
=COUNTIF('Action Log'!G23:G83,"LS")-COUNTIFS('Action Log'!I23:I83,"Yes")
TIA Karen

• Hi! If both of your conditions must be met simultaneously, use the COUNTIFS function to calculate the quantity of values. Read this article above.
Try this formula:

=COUNTIFS('Action Log'!G23:G83,"LS",'Action Log'!I23:I83,"Yes")

46. I am trying to incorporate wildcards into a COUNTIFS with three criteria because the data is coming from a sharepoint and sometimes includes date and time and sometimes only date and I need to look only at dates. So far this is what I have.

=COUNTIFS('WT Outflow Import'!B:B,\$B\$4,'WT Outflow Import'!A:A,C18,'WT Outflow Import'!C:C,\$B\$6)

B6 is the cell containing the date.

The above formula returns what I need if there is no time present with the date in the cell. Otherwise it returns nothing as expected. I need the value matches regardless of whether there is date/time or just date. This is a sharepoint connection, so I don't have the luxury of just changing the data.

I tried using a wildcard and it also returns nothing.

=COUNTIFS('WT Outflow Import'!B:B,\$B\$4,'WT Outflow Import'!A:A,C18,'WT Outflow Import'!C:C,\$B\$6&"*")

Any idea where I am going wrong here?

• Is it because the column where I am parsing using the wildcard is a date (number)?

• Hi! To use only the date and ignore the time, round up the date and time to a integer number. For example, using the INT function: as INT(\$B\$6)