COUNTIF function
This article describes the formula syntax and usage of the COUNTIFfunction in Microsoft Office Excel.
Description
The COUNTIF function counts the number of cells within a range that meet a single criterion that you specify. For example, you can count all the cells that start with a certain letter, or you can count all the cells that contain a number that is larger or smaller than a number you specify. For example, suppose you have a worksheet that contains a list of tasks in column A, and the first name of the person assigned to each task in column B. You can use the COUNTIF function to count how many times a person's name appears in column B and, in that way, determine how many tasks are assigned to that person. For example:
=COUNTIF(B2:B25,"Nancy")
Note To count cells based on multiple criteria, see COUNTIFS function.
Syntax
COUNTIF(range, criteria)
The COUNTIF function syntax has the following arguments:

range Required. One or more cells to count, including numbers or names, arrays, or references that contain numbers. Blank and text values are ignored.

criteria Required. A number, expression, cell reference, or text string that defines which cells will be counted. For example, criteria can be expressed as 32, ">32", B4, "apples", or "32".
Note

You can use the wildcard characters — the question mark (?) and the asterisk (*) — in criteria. A question mark matches any single character, and an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) before the character.

Criteria are case insensitive; for example, the string "apples" and the string "APPLES" will match the same cells.

Example 1: Common COUNTIF formulas
The example may be easier to understand if you copy it to a blank worksheet.
How do I copy an example?

Select the example in this article.
Important Do not select the row or column headers.
Selecting an example from Help

Press CTRL+C.

In Excel, create a blank workbook or worksheet.

In the worksheet, select cell A1, and press CTRL+V.
Important For the example to work properly, you must paste it into cell A1 of the worksheet.

To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.
After you copy the example to a blank worksheet, you can adapt it to suit your needs.


Example 2: COUNTIF formulas using wildcard characters and handling blank values
The example may be easier to understand if you copy it to a blank worksheet.
How do I copy an example?

Select the example in this article.
Important Do not select the row or column headers.
Selecting an example from Help

Press CTRL+C.

In Excel, create a blank workbook or worksheet.

In the worksheet, select cell A1, and press CTRL+V.
Important For the example to work properly, you must paste it into cell A1 of the worksheet.

To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.
After you copy the example to a blank worksheet, you can adapt it to suit your needs.


Note To view a number as a percentage, select the cell and then, on the Sheet tab, in the Number group, click Percentage Style .