How to count cells by criteria

Excel 2016 2013 2010 2007 2003
Use COUNTIF if you need to sum values for a particular person or another criterion.

To count cells by criteria, do the following:

   1.   Select the cell where want Excel to return the number of the cell by criteria.

COUNTIF example Excel 365

   2.   Do one of the following:

  • On the Formula tab, in the Function Library group, select the More Functions button and then select Statistical:
    Statistical Formulas in Excel 365

    Choose COUNTIF in the list.

  • Click the Insert Function button Insert Function button in the left of the Formula bar:
    Edit bar in Excel 365

    In the Insert Function dialog box:

    • select Statistical in the Or select a category drop-down list,
    • select COUNTIF in the Select a function list:
    Insert Function Excel 365

   3.   In the Function Arguments dialog box:

Function Arguments Excel 365
  • The Range field determines the range of cells Excel will look to perform the count in. In this example, the cell range is D2:D17.
  • The Criteria is a conditional statement that is similar to the conditional statement in the IF statement.

   4.   Press OK:

COUNTIF example Excel 365


  • You can enter this formula using the keyboard, for this example:

    = COUNTIF (D2:D17, ">300")

  • If you want to use COUNTIF on a selection of cells (not necessarily one solid range), summing multiple COUNTIFs:

    = SUM (COUNTIF (D3, ">200"), COUNTIF (D7, ">200"), COUNTIF (D14, ">200"), COUNTIF (D17, ">200"))

  • You can use the wildcard characters, the question mark (?), the asterisk (*) in the criteria. A question mark matches any single character; an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) before the character.
  • Microsoft Excel provides additional functions that can be used to analyze your data based on a condition.
    • To calculate a sum based on a string of text or a number within a range, use the SUMIF worksheet function (see How to sum cells by criteria for more details).
    • To have a formula return one of two values based on a condition, such as a sales bonus based on a specified sales amount, use the IF worksheet function.
    • To count cells that are empty or not empty, use the COUNTA and COUNTBLANK functions.

See also this tip in French: Comment compter les cellules par critères.

If you have any questions or suggestions, please feel free to ask OfficeToolTips team.

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information you’ve provided to them or they’ve collected from your use of their services.

Learn more