MS Excel: COUNTIFS Function (WS)
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] )
Parameters or Arguments
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:
- Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007
Type of Excel Function
The COUNTIFS function can be used in Microsoft Excel as the following type of function:
- Worksheet function (WS)
Example (as Worksheet Function)
Let's look at some Excel COUNTIFS function examples and explore how you would 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")||would return 4
(applies 1 criteria)
|=COUNTIFS(A2:A9,"=2013",B2:B9,"=Oranges")||would return 2
(applies 2 criteria)
|=COUNTIFS(A2:A9,">=2009",B2:B9,"=Oranges", A2:A9,"<=2012")||would return 1
(applies 3 critiera)
|=COUNTIFS(A2:A9,">=2009",B2:B9,"=B*")||would return 2
(Uses the * wildcard to match on all products that start with B)
|=COUNTIFS(A2:A9,">=2009",B2:B9,"=B?nanas")||would return 2
(Uses the ? wildcard to match on a single character, ie: Bananas, Benanas, Binanas, Bonanas, and so on)
Using Named Ranges
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")||would return 2|
|=COUNTIFS(products,"=Oranges",A2:A9,"<2014")||would return 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.