Learn how to use the Excel COUNTIFS function with syntax and examples.
The Microsoft Excel COUNTIFS function counts the number of cells in a range, that meets a single or multiple criteria.
The syntax for the Microsoft Excel COUNTIFS function is:
COUNTIFS( criteria_range1, criteria1, [criteria_range2, criteria2, ... criteria_range_n, criteria_n] )
criteria_range1 is the range of cells that you want to apply criteria1 against.
criteria1 is used to determine which cells to count. criteria1 is applied against criteria_range1.
criteria_range2, ... criteria_range_n is optional. It is the range of cells that you want to apply criteria2, ... criteria_n against. There can be up to 127 ranges.
criteria2, ... criteria_n is optional. It is used to determine which cells to count. criteria2 is applied against criteria_range2, criteria3 is applied against criteria_range3, and so on. There can be up to 127 criteria.
The COUNTIFS function can be used in the following versions of Microsoft Excel:
The COUNTIFS function can be used in Microsoft Excel as the following type of function:
Let's look at some Excel COUNTIFS function examples and explore how to use the COUNTIFS function as a worksheet function in Microsoft Excel:
Based on the spreadsheet above, the following Excel COUNTIFS examples would return:
=COUNTIFS(A2:A9,"=2013") Result: 4 (applies 1 criteria) =COUNTIFS(A2:A9,"=2013",B2:B9,"=Oranges") Result: 2 (applies 2 criteria) =COUNTIFS(A2:A9,">=2009",B2:B9,"=Oranges", A2:A9,"<=2012") Result: 1 (applies 3 critiera) =COUNTIFS(A2:A9,">=2009",B2:B9,"=B*") Result: 2 (Uses the * wildcard to match on all products that start with B) =COUNTIFS(A2:A9,">=2009",B2:B9,"=B?nanas") Result: 2 (Uses the ? wildcard to match on a single character, ie: Bananas, Benanas, Binanas, Bonanas, and so on)
You can also use a named range in the COUNTIFS function. For example, we've created a named range called products that refers to column B in Sheet 1.
Then we've entered the following data in Excel:
Based on the Excel spreadsheet above:
=COUNTIFS(products,"=Apples",A2:A9,">2010") Result: 2 =COUNTIFS(products,"=Oranges",A2:A9,"<2014") Result: 3
To view named ranges: Select the Formulas tab in the toolbar at the top of the screen. Then in the Defined Names group, click on the Defined Names drop-down and select Name Manager.
The Name Manager window should now appear.