Excel function

COUNTIFfunction

Counts the cells in a range that meet a condition.

All versions
=COUNTIF(B2:B9, "Apple")
A
B
C
D
1
2
3
4
5
6
7
8
9

Drag the corner dots to change range. Click a cell in the criteria range to use its value as the criteria. Move range to column C (Qty) and set criteria to ">=20" to count quantities of 20 or more. Try breaking it on purpose to see the errors.

Result

3

range
B2:B9Drag a corner dot up/down to resize, sideways to change the column

The column to check.

criteria

The condition that picks the cells to count.

What is the COUNTIF function?

=COUNTIF(range, criteria)

COUNTIF counts how many cells in a range meet one condition: how many orders came from Seoul, how many scores are 80 or more, how many cells are blank.

It counts cells, not values. To add values instead, use SUMIF.

Arguments

range
The cells to check and count.
criteria
The condition. Type a value such as "Seoul", a comparison such as ">=20" or "<>Seoul", or a wildcard pattern such as "B*" (* for any characters, ? for one character). Text and comparisons go in double quotes. Use "" to count blank cells and "<>" to count non-blank cells.

COUNTIF examples

  1. Example 1. Count one product

    =COUNTIF(B2:B9, "Apple")

    Apple appears in 3 rows, so the result is 3.

  2. Example 2. Count quantities of 20 or more

    =COUNTIF(C2:C9, ">=20")

    30, 20, 40 and 25 match, so the result is 4.

  3. Example 3. Find duplicates

    =COUNTIF($B$2:$B$9, B2)>1

    Copied down, this is TRUE for every product that appears more than once.

Common mistakes

FAQ

How do I count with two conditions?
Use COUNTIFS, which counts rows where every condition is TRUE.