Excel COUNTIF

COUNTIF counts how many cells in a range match one condition.

A small online shop wants to know how many reviews gave four stars or better and which product is reviewed most. COUNTIF answers both from one column, and it is also the simplest way to spot duplicates.

Practice it now

How to write it

=COUNTIF(range, criteria)
range
The cells to test.
criteria
The condition to meet.

Watch it work

D2fx 
ABCDE
1ProductRating
2Mug5
3Mug3
4Cap4
5Bag5
6Cap2
7Mug4
8
1

Text conditions go in quotes.

Examples

How many reviews are for the Mug?

=COUNTIF(A2:A7,"Mug")3

Text conditions go in quotes.

Ratings of 4 or better

=COUNTIF(B2:B7,">=4")4

Comparison operators go inside the quotes.

Reviews not about the Cap

=COUNTIF(A2:A7,"<>Cap")4

The <> operator counts everything else.

Your turn

Count how many ratings are exactly 5. Type your formula in D2.

ABCD
1ProductRating
2Mug5
3Mug3
4Cap4
5Bag5
6Cap2
7Mug4
8

Common mistakes

Using a cell inside a comparison incorrectly.

Join them: ">"&D1, not ">D1".

Long codes match when they shouldn't.

Very long numeric text can be compared as numbers. Check IDs longer than 15 digits.

Good to know

  • COUNTIF(A:A,A2)>1 flags duplicates.
  • Divide by COUNTA to turn a count into a share of the total.
  • COUNTIF or COUNTIFS? COUNTIF has one condition. COUNTIFS needs every one of several conditions to be true.