How to Count Data in Selected Cells with Excel's COUNTIF Function

Count and better manage your data with Excel's COUNTIF Function
Monty Rakusen / Getty Images

The COUNTIF function combines the IF function and COUNT function in Excel. This combination counts the number of times specific data is found in a selected group of cells. The IF portion of the function determines what data meets the specified criteria and the COUNT part does the counting.

Instructions in this article apply to Excel 2019, 2016, 2013, 2010, 2007; Excel for Office 365, Excel Online, Excel for Mac, Excel for iPad, Excel for iPhone, and Excel for Android.

Excel COUNTIF Function Syntax

In Excel, a function's syntax refers to the layout of the function and includes the function's name, brackets, and arguments. The syntax for the COUNTIF function is:

Screenshot of Excel showing the COUNTIF Function in action

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.

A screenshot showing data used with the COUNTIF function in Excel

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.

  1. Select cell E12 to make it the active cell. This is where the COUNTIF function will be entered.

  2. Select the Formulas tab of the ribbon.

  3. Choose More Functions > Statistical.

  4. Select COUNTIF in the list to open the Function Arguments dialog box. In Excel for Mac, the Function Builder opens.

    Screenshot of Excel showing the COUNTIF Function Arguments dialog box

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.

  1. 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.

  2. 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.

  1. Place the cursor in the Criteria text box.

  2. 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.

  3. 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.

  1. Select cell D12. This is the cell identified in the function as containing the criteria argument.

  2. Type >250 and press Enter.

    A screenshot showing the results of the COUNTIF function in Excel
  3. The number 4 appears in cell E12.