What to Know
- Syntax: "=COUNTIF([range],[criteria])" where range = group of cells and criteria = value with range data.
- Set up: Enter example data > select cell > Formulas tab > More Functions > Statistical > COUNTIF.
- Highlight range: Place cursor in Range text box in Function Arguments dialog box > select cells.
This article explains how to use the COUNTIF function in selected cells in Excel 2019, 2016, 2013, 2010, 2007, Excel for Microsoft 365, Excel Online, for Mac, iPad, iPhone, and Android.
Excel COUNTIF Function Syntax
The function's arguments tell the function what condition is being tested for and what range of data to count when the condition is met.
- Range: The group of cells the function is to search.
- Criteria: The value compared with the data in the Range cells. If a match is found, the cell in the Range is counted. Actual data or the cell reference to the data can be entered for this argument.
Enter the Example Data
Follow the steps in this article to create and use the COUNTIF function. In this example, the COUNTIF function counts the number of sales representatives with more than 250 orders.
The first step to using the COUNTIF function in Excel is to enter the data. Enter the data into cells C1 to E11 of an Excel worksheet as shown in the image above. The COUNTIF function and the search criteria (greater than 250 orders) will be added to row 12 below the data.
The tutorial instructions do not include formatting steps for the worksheet. Your worksheet will look different than the example shown, but the COUNTIF function will give you the same results.
Build the COUNTIF Function
Although it is possible to type the COUNTIF function into a cell in a worksheet, it's easier to use the built-in COUNTIF function in Excel to enter the function.
Select cell E12 to make it the active cell. This is where the COUNTIF function will be entered.
Select the Formulas tab of the ribbon.
Choose More Functions > Statistical.
Select COUNTIF in the list to open the Function Arguments dialog box. In Excel for Mac, the Function Builder opens.
The data entered into the two blank rows in the dialog box form the arguments of the COUNTIF function. These arguments tell the function what condition is being tested for and what cells to count when the condition is met.
Highlight the Range Argument
The Range argument tells the COUNTIF function which group of cells to search when trying to find the specified criteria.
In the Function Arguments dialog box (or the Formula Builder if you're working on a Mac), place the cursor in the Range text box.
Highlight cells E3 to E9 on the worksheet to enter these cell references as the range to be searched by the function.
Specify the Criteria Argument
The Criteria argument tells COUNTIF what data it should find in the Range argument. Although actual data (such as text or numbers like >250) can be entered for this argument, it is best to enter a cell reference into the dialog box (such as D12) and enter the data you want to match into that cell in the worksheet.
Place the cursor in the Criteria text box.
Select cell D12 to enter that cell reference. The function searches the range selected in the previous step for data that matches whatever data is entered into this cell.
Select OK when you're finished. On a Mac, select Done to complete the function.
An answer of zero appears in cell E12 (the cell where the function was entered) because data has not been added to the Criteria field (cell D12).
Add the Search Criteria
The last step in the tutorial is to add the criteria the function will match. In this case, the number of Sales Reps with more than 250 orders for the year will be counted.
Select cell D12. This is the cell identified in the function as containing the criteria argument.
Type >250 and press Enter.
The number 4 appears in cell E12.