How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (2024)

Excel has many functions where a user needs to specify a single or multiple criteria to get the result. For example, if you want to count cells based on multiple criteria, you can use the COUNTIF or COUNTIFS functions in Excel.

This tutorial covers various ways of using a single or multiple criteria in COUNTIF and COUNTIFS function in Excel.

While I will primarily be focussing on COUNTIF and COUNTIFS functions in this tutorial, all these examples can also be used in other Excel functions that take multiple criteria as inputs (such as SUMIF, SUMIFS, AVERAGEIF, and AVERAGEIFS).

This Tutorial Covers:

An Introduction to Excel COUNTIF and COUNTIFS Functions

Let’s first get a grip on using COUNTIF and COUNTIFS functions in Excel.

Excel COUNTIF Function (takes Single Criteria)

Excel COUNTIF function is best suited for situations when you want to count cells based on a single criterion. If you want to count based on multiple criteria, use COUNTIFS function.

Syntax

=COUNTIF(range, criteria)

Input Arguments

  • range – the range of cells which you want to count.
  • criteria – the criteria that must be evaluated against the range of cells for a cell to be counted.

ExcelCOUNTIFS Function (takes Multiple Criteria)

Excel COUNTIFS function is best suited for situations when you want to count cells based on multiple criteria.

Syntax

=COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2]…)

Input Arguments

  • criteria_range1 – The range of cells for which you want to evaluate against criteria1.
  • criteria1 – the criteria which you want to evaluate for criteria_range1 to determine which cells to count.
  • [criteria_range2] –The range of cells for which you want to evaluate against criteria2.
  • [criteria2] –the criteria which you want to evaluate for criteria_range2 to determine which cells to count.

Now let’s have a look at some examples of using multiple criteria in COUNTIF functions in Excel.

Using NUMBER Criteria inExcel COUNTIF Functions

#1 Count Cells when Criteria is EQUAL to a Value

To get the count of cells where the criteria argument is equal to a specified value, you can either directly enter the criteria or use the cell reference that contains the criteria.

Below is an example where we count the cells that contain the number 9 (which means that the criteria argument is equal to 9). Here is the formula:

=COUNTIF($B$2:$B$11,D3)

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (1)

In the above example (in the pic), the criteria is in cell D3. You can also enter the criteria directly into the formula. For example, you can also use:

=COUNTIF($B$2:$B$11,9)

#2 Count Cells when Criteria is GREATER THAN a Value

To get the count of cells with a value greater than a specified value, we use the greater than operator (“>”). We could either use it directly in the formula or use a cell reference that has the criteria.

Whenever we use an operator in criteria in Excel, we need to put it within double quotes. For example, if the criteria isgreater than 10, then we need to enter “>10” as the criteria (see pic below):

Here is the formula:

=COUNTIF($B$2:$B$11,”>10″)

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (2)

You can also have the criteria in a cell and use the cell reference as the criteria. In this case, you need NOT put the criteria in double quotes:

=COUNTIF($B$2:$B$11,D3)

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (3)

There could also be a case when you want the criteria to be in a cell, but don’t want it with the operator. For example, you may want the cell D3 to have the number 10 and not >10.

In that case, you need to create a criteria argument which is a combination ofoperator and cell reference (see pic below):

=COUNTIF($B$2:$B$11,”>”&D3)

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (4)NOTE: When you combine an operator and a cell reference, the operator is always in double quotes.The operator and cell reference are joined by an ampersand (&).

Also read: Count Cells Less than a Value in Excel (COUNTIF Less Than)

#3 Count Cells when Criteria is LESS THAN a Value

To get the count of cells with a value less than a specified value, we use the less than operator (“<“). We could either use it directly in the formula or use a cell reference that has the criteria.

Whenever we use an operator in criteria in Excel, we need to put it within double quotes. For example, if the criterion is that the number should be less than 5, then we need to enter “<5” as the criteria (see pic below):

=COUNTIF($B$2:$B$11,”<5″)

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (5)

You can also have the criteria in a cell and use the cell reference as the criteria. In this case, you need NOT put the criteria in double quotes (see pic below):

=COUNTIF($B$2:$B$11,D3)

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (6)

Also, there could be a case when you want the criteria to be in a cell, but don’t want it with the operator. For example, you may want the cell D3 to have the number 5and not <5.

In that case, you need to create a criteria argument which is a combination ofoperator and cell reference:

=COUNTIF($B$2:$B$11,”<“&D3)

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (7)

NOTE: When you combine an operator and a cell reference, the operator is always in double quotes.The operator and cell reference are joined by an ampersand (&).

#4 Count Cells with Multiple Criteria –BetweenTwo Values

To get a count of values between two values, we need to use multiple criteria in the COUNTIF function.

Here are two methods of doing this:

METHOD 1: Using COUNTIFS function

COUNTIFS function can handle multiple criteria as arguments and counts the cells only when all the criteria are TRUE. To count cells with values between two specified values (say 5 and 10), we can use the following COUNTIFS function:

=COUNTIFS($B$2:$B$11,”>5″,$B$2:$B$11,”<10″)

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (8)

NOTE: The above formula does not count cells that contain 5 or 10. If you want to include these cells, use greater than equal to (>=) and less than equal to (<=) operators. Here is the formula:

=COUNTIFS($B$2:$B$11,”>=5″,$B$2:$B$11,”<=10″)

You can also have these criteria in cells and use the cell reference as the criteria. In this case, you need NOT put the criteria in double quotes (see pic below):

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (9)

You can also use a combination of cells references and operators (where the operator is entered directly in the formula). When you combine an operator and a cell reference, the operator is always in double quotes. The operator and cell reference are joined by an ampersand (&).

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (10)

METHOD 2: Using two COUNTIF functions

If you have multiple criteria, you can either use COUNTIFS or create a combination of COUNTIF functions. The formula below would also do the same thing:

=COUNTIF($B$2:$B$11,”>5″)-COUNTIF($B$2:$B$11,”>10″)

In the above formula, we first find the number of cells that have a value greater than 5 and we subtract the count of cells with a value greater than 10. This would give us the result as 5 (which is the number of cells that have values more than 5 and less than equal to 10).

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (11)

If you want the formula toincludeboth 5 and 10, use the following formula instead:

=COUNTIF($B$2:$B$11,”>=5″)-COUNTIF($B$2:$B$11,”>10″)

If you want the formula to exclude both ‘5’ and ’10’ from the counting, use the following formula:

=COUNTIF($B$2:$B$11,”>=5″)-COUNTIF($B$2:$B$11,”>10″)-COUNTIF($B$2:$B$11,10)

You can have these criteria in cells and use the cells references, or you can use a combination of operators and cells references.

Also read: SUM Based on Partial Text Match in Excel (SUMIF)

Using TEXT Criteria inExcel Functions

#1 Count Cells when Criteria is EQUAL toa Specified text

To count cells that contain an exact match of the specified text, we can simply use that text as the criteria. For example, in the dataset (shown below in the pic), if I want to count all the cells with the name Joe in it, I can use the below formula:

=COUNTIF($B$2:$B$11,”Joe”)

Since this is a text string, I need to put the text criteria in double quotes.

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (12)

You can also have the criteria in a cell and then use that cell reference (as shown below):

=COUNTIF($B$2:$B$11,E3)

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (13)

NOTE: You can get wrong results if there are leading/trailing spaces in the criteriaor criteria range. Make sure youclean the data before using these formulas.

#2 Count Cells when Criteria is NOTEQUAL toa Specified text

Similar to what we saw in the above example, you can also count cells that do not contain a specified text. To do this, we need to use the not equal to operator (<>).

Suppose you want to count all the cells that donot contain the name JOE, here is the formula that will do it:

=COUNTIF($B$2:$B$11,”<>Joe”)

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (14)

You can also have the criteria in a cell and use the cell reference as the criteria. In this case, you need NOT put the criteria in double quotes (see pic below):

=COUNTIF($B$2:$B$11,E3)

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (15)

There could also be a case when you want the criteria to be in a cell but don’t want it with the operator. For example, you may want the cell D3 to have the name Joe and not <>Joe.

In that case, you need to create a criteria argument which is a combination ofoperator and cell reference (see pic below):

=COUNTIF($B$2:$B$11,”<>”&E3)

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (16)

When you combine an operator and a cell reference, the operator is always in double quotes. The operator and cell reference are joined by an ampersand (&).

Using DATE Criteria inExcel COUNTIF and COUNTIFS Functions

Excel store date and time as numbers. So we can use it the same way we use numbers.

#1 Count Cells when Criteria is EQUAL toa SpecifiedDate

To get the count of cells that contain the specified date, we would use the equal to operator (=) along with the date.

To use the date, I recommend using the DATE function, as it gets rid of any possibility of error in the date value. So, for example, if I want to use the date September 1, 2015, I can use the DATE functionas shown below:

=DATE(2015,9,1)

This formula would return the same date despite regional differences. For example, 01-09-2015 would be September 1, 2015 according to the US date syntax and January 09, 2015 according to the UK date syntax. However, this formula would always return September 1, 2105.

Here is the formula to count the number of cells that contain the date 02-09-2015:

=COUNTIF($A$2:$A$11,DATE(2015,9,2))

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (17)

#2 Count Cells when Criteria is BEFOREor AFTERtoa SpecifiedDate

To count cells that contain datebefore or after a specified date, we can use the less than/greater than operators.

For example, if I want to count all the cells that contain a date that is after September 02, 2015, I can use the formula:

=COUNTIF($A$2:$A$11,”>”&DATE(2015,9,2))

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (18)

Similarly, you can also count the number of cells before a specified date. If you want to include a date in the counting, useand ‘equal to’operator along with ‘greater than/less than’operator.

You can also use a cell reference that contains a date. In this case, you need to combine the operator (within double quotes) with the date using an ampersand (&).

See example below:

=COUNTIF($A$2:$A$11,”>”&F3)

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (19)

#3 Count Cells with Multiple Criteria –BetweenTwoDates

To get a count of values between two values, we need to use multiple criteria in the COUNTIF function.

We can do this using two methods – One single COUNTIFS function or two COUNTIF functions.

METHOD 1: Using COUNTIFS function

COUNTIFS function can take multiple criteria as the arguments and counts the cells only when all the criteria are TRUE. To count cells with values between two specified dates (say September 2 and September 7), we can use the following COUNTIFS function:

=COUNTIFS($A$2:$A$11,”>”&DATE(2015,9,2),$A$2:$A$11,”<“&DATE(2015,9,7))

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (20)

The above formula does not count cells that contain the specified dates. If you want to include these dates as well, use greater than equal to (>=) and less than equal to (<=) operators. Here is the formula:

=COUNTIFS($A$2:$A$11,”>=”&DATE(2015,9,2),$A$2:$A$11,”<=”&DATE(2015,9,7))

You can also have the dates in a cell and use the cell reference as the criteria. In this case, you can not have the operator with the date in the cells. You need to manually add operators in the formula (in double quotes) and add cell reference using an ampersand (&). See the pic below:

=COUNTIFS($A$2:$A$11,”>”&F3,$A$2:$A$11,”<“&G3)

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (21)

METHOD 2: Using COUNTIF functions

If you have multiple criteria, you can either use one COUNTIFS function or create a combination of two COUNTIF functions. The formula below would also do the trick:

=COUNTIF($A$2:$A$11,”>”&DATE(2015,9,2))-COUNTIF($A$2:$A$11,”>”&DATE(2015,9,7))

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (22)

In the above formula, we first find the number of cells that have a date after September 2 and we subtract the count of cells with dates after September 7. This would give us the result as 7(which is the number of cells that have dates after September 2 and on or before September 7).

If you don’t want the formula to count both September 2 and September 7, use the following formula instead:

=COUNTIF($A$2:$A$11,”>=”&DATE(2015,9,2))-COUNTIF($A$2:$A$11,”>”&DATE(2015,9,7))

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (23)

If you want to exclude both the dates from counting, use the following formula:

=COUNTIF($A$2:$A$11,”>”&DATE(2015,9,2))-COUNTIF($A$2:$A$11,”>”&DATE(2015,9,7)-COUNTIF($A$2:$A$11,DATE(2015,9,7)))

Also, you can have the criteria dates in cells and use the cells references (along with operators in double quotes joined using ampersand).

Using WILDCARD CHARACTERS in Criteria in COUNTIF &COUNTIFSFunctions

There are three wildcard characters in Excel:

  1. * (asterisk) – It represents any number of characters. For example, ex* could mean excel, excels, example, expert, etc.
  2. ? (question mark) – It representsonesingle character.For example, Tr?mp could mean Trump or Tramp.
  3. ~ (tilde) – It is used to identify a wildcard character (~, *, ?) in the text.

You can use COUNTIF function with wildcard characters to count cells when other inbuilt count function fails. For example, suppose you have a data set as shown below:

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (24)

Now let’s take various examples:

#1 Count Cells that contain Text

To count cells with text in it, we can use the wildcard character * (asterisk). Since asterisk represents any number of characters, it would count all cells that have any text in it. Here is the formula:

=COUNTIFS($C$2:$C$11,”*”)

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (25)

Note: The formula above ignores cells that contain numbers, blank cells, and logical values, but would count the cells contain an apostrophe (and hence appear blank) or cells that contain empty string (=””) which may have been returned as a part of a formula.

Here is a detailed tutorial on handling cases where there is an empty string or apostrophe.

Here is adetailed tutorial on handling cases where there are empty strings or apostrophes.

Below is a video that explains different scenarios of counting cells with text in it.

#2 CountNon-blank Cells

If you are thinking of using COUNTA function, think again.

Try it and it might fail you. COUNTA will also count a cell that contains an empty string (often returned by formulas as =”” or when people enter onlyan apostrophe in a cell). Cells that contain empty strings look blank but are not, and thus counted by the COUNTA function.

COUNTA will also count a cell that contains an empty string (often returned by formulas as =”” or when people enter onlyan apostrophe in a cell). Cells that contain empty strings look blank but are not, and thus counted by the COUNTA function.

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (26)

So if you use the formula =COUNTA(A1:A11), it returns 11, while it should return 10.

Here is the fix:

=COUNTIF($A$1:$A$11,”?*”)+COUNT($A$1:$A$11)+SUMPRODUCT(–ISLOGICAL($A$1:$A$11))

Let’s understand this formula by breaking it down:

  • COUNTIF($N$8:$N$18,”?*”) – This part of the formula returns 5. This includes any cell that has a text character in it. A ? represents one character and * represents any number of characters. Hence, the combination ?* in the criteria forces excel to count cells that have at least one text character in it.How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (27)
  • COUNT($A$1:$A$11) – This counts all the cells that contain numbers. In the above example, it returns 3.How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (28)
  • SUMPRODUCT(–ISLOGICAL($A$1:$A$11) – This counts all the cells that containlogical values.In the above example, it returns 2.How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (29)

#3 Count Cells that contain specific text

Let’s say we want to count all the cells where the sales rep name begins with J. This can easily be achieved by using a wildcard character in COUNTIF function. Here is the formula:

=COUNTIFS($C$2:$C$11,”J*”)

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (30)

The criteria J* specifies that the text in a cell should begin with J and can contain any number of characters.

If you want to count cells that contain the alphabet anywhere in the text, flank it with an asterisk on both sides. For example, if you want to count cells that contain the alphabet “a” in it, use *a* as the criteria.

This article is unusually long compared to my other articles. Hope you have enjoyed it. Let me know your thoughts by leaving a comment.

You May Also Find the following Excel tutorials useful:

  • Count the number of words in Excel.
  • Count Cells Based on Background Color in Excel.
  • How to Sum a Column in Excel (5 Really Easy Ways)
How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS (2024)

FAQs

How to Use Multiple Criteria in Excel COUNTIF and COUNTIFS? ›

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.

Can you use Countif and Countifs together? ›

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.

What is the difference between Countif and Countifs? ›

The difference between COUNTIF and COUNTIFS 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 different ranges. When doing financial analysis, COUNTIF helps in doing a quick analysis.

Can you do a countif with multiple criteria sheets? ›

COUNTIFS function Google Sheets to count values by multiple criteria. The COUNTIFS function is a hybrid of COUNT and IFS functions. It allows you to check multiple ranges with multiple criteria. The formula returns the count based on the criteria met.

How to do a countif with two conditions? ›

Step 1: Document the criteria or conditions you wish to test for. Step 2: Type “=countifs(“ and select the range you want to test the first criteria on. Step 3: Input the test for the criteria. Step 4: Select the second range you want to test (it can be the same range again, or a new one).

How do you use Countifs with multiple ranges? ›

The COUNTIFS will only count rows where all criteria are true. The way it works is that you list a column or range (e.g. your "Range 1") then a criteria (your "Cardiology"). Then you list another column or range ("Range 2") and your next criteria ("YES"). These have to be true in the same row.

How to use countifs formula in Excel with example? ›

For example, given the following table, the COUNTIFS excel function can count the total number of products with the name “B” for the east region. The formula “=COUNTIFS(A2:A13,“EAST”,B2:B13,“B”)” returns 2. The COUNTIFS is different from the COUNTIF. It is used to count cells that include dates, numbers, or text.

What is an example of when you should use a Countifs function? ›

Excel COUNTIF function is used for counting cells within a specified range that meet a certain criterion, or condition. For example, you can write a COUNTIF formula to find out how many cells in your worksheet contain a number greater than or less than the number you specify.

How to write a countifs formula? ›

COUNTIF Function

The generic syntax is COUNTIF(range, criteria), where "range" contains the cells to count, and "criteria" is a condition that must be true for a cell to be counted.

Can I use countifs with 3 criteria? ›

Instead of running a COUNTIFS for each criterion, put all three in one COUNTIFS statement. This will require all 3 of the criteria to be true in a single row to be counted.

Can we enter multiple if conditions in an if formula in Excel? ›

While Excel will allow you to nest up to 64 different IF functions, it's not at all advisable to do so. Why? Multiple IF statements require a great deal of thought to build correctly and make sure that their logic can calculate correctly through each condition all the way to the end.

What are the logical operators for Countifs? ›

The COUNTIF function is also very useful with numbers. You can count cells that have values more or less than a certain number. Use logical operators like > (more than), < (less than), <> (not the same as), <= (less than or the same as), and >= (more than or the same as).

What is the difference between Countifs and Sumifs? ›

COUNTIFS applies criteria to cells across multiple ranges and counts the number of times all criteria are met. SUMIFS adds the cells in a range that meet multiple criteria.

How do you count cells if another cell meets criteria in Excel? ›

Excel COUNTIF Function
  1. Select a cell.
  2. Type =COUNTIF.
  3. Double click the COUNTIF command.
  4. Select a range.
  5. Type ,
  6. Select a cell (the criteria, the value that you want to count)
  7. Hit enter.

How to use countif in spreadsheet? ›

To use the COUNTIF function in Google Sheets, enter the function followed by the range and the criterion within the parentheses. For example, if you want to count the number of cells in the range A1:A10 that contain the text "apple", you would enter the formula "=COUNTIF(A1:A10, "apple")" into a cell.

Why do we use Countifs instead of the Countif versions of the functions in Excel? ›

COUNTIF is used to count items based on one criterion, while COUNTIFS is used to count items based on multiple criteria.

Can you use indirect with Countifs? ›

The INDIRECT function can be used with a number of functions that accept a cell reference as an argument, such as the SUM and COUNTIF functions.

How to count multiple values in one cell in Excel? ›

Count how often multiple text or number values occur by using the SUM and IF functions together. In the examples that follow, we use the IF and SUM functions together. The IF function first tests the values in some cells and then, if the result of the test is True, SUM totals those values that pass the test.

Top Articles
Latest Posts
Article information

Author: Corie Satterfield

Last Updated:

Views: 6622

Rating: 4.1 / 5 (62 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Corie Satterfield

Birthday: 1992-08-19

Address: 850 Benjamin Bridge, Dickinsonchester, CO 68572-0542

Phone: +26813599986666

Job: Sales Manager

Hobby: Table tennis, Soapmaking, Flower arranging, amateur radio, Rock climbing, scrapbook, Horseback riding

Introduction: My name is Corie Satterfield, I am a fancy, perfect, spotless, quaint, fantastic, funny, lucky person who loves writing and wants to share my knowledge and understanding with you.