Free COUNTIF practice

COUNTIF practice exercises

COUNTIF counts the cells in a range that meet a single condition. 5 reps, from easy to hard, each checked in a real spreadsheet engine. 2 free, 3 with Pro.

=COUNTIF(range, criteria)
Skill: COUNTIF Change skill (45)

COUNTIF guide

How to use COUNTIF in Excel

COUNTIF counts the cells in a range that meet one condition: how many tickets are open, how many orders are over 100, how many names start with A. It's one of the first functions most Excel tests ask for.

For more than one condition at once, use COUNTIFS, which works the same way with extra range and criteria pairs.

Syntax

=COUNTIF(range, criteria)
ArgumentWhat it is
rangeThe cells to check, such as B2:B7.
criteriaWhat to count: text in quotes ("Open"), a cell (E2), a comparison in quotes (">4", or ">"&E2 to use a cell), or a wildcard ("*late*").

Examples

Example 1 Count a status. How many tickets are Open.
E2fx=COUNTIF(B2:B7,"Open")
ABCDE
1TicketStatusHoursOpen tickets
2T-1Open33
3T-2Closed5
4T-3Open8
5T-4Pending2
6T-5Closed12
7T-6Open1

=COUNTIF(B2:B7,"Open") returns 3.

Example 2 Count numbers above a limit. How many tickets took more than 4 hours. The comparison goes in quotes.
E2fx=COUNTIF(C2:C7,">4")
ABCDE
1TicketStatusHoursOver 4 hours
2T-1Open33
3T-2Closed5
4T-3Open8
5T-4Pending2
6T-5Closed12
7T-6Open1

=COUNTIF(C2:C7,">4") returns 3.

Example 3 Count everything except one value. "<>Closed" means not equal to Closed, so Open and Pending tickets both count.
E2fx=COUNTIF(B2:B7,"<>Closed")
ABCDE
1TicketStatusHoursNot closed
2T-1Open34
3T-2Closed5
4T-3Open8
5T-4Pending2
6T-5Closed12
7T-6Open1

=COUNTIF(B2:B7,"<>Closed") returns 4.

Common mistakes

Counting text with COUNT

COUNT only counts cells that contain numbers, so it returns 0 for a column of text. Use COUNTIF with a condition, or COUNTA to count every non-empty cell.

Wrong=COUNT(B2:B7) → 0

Right=COUNTIF(B2:B7,"Open") → 3

An extra space in the criteria

"Open " with a trailing space doesn't match Open. Check the criteria (and the data) for stray spaces; TRIM removes them from data.

Wrong=COUNTIF(B2:B7,"Open ") → 0

Right=COUNTIF(B2:B7,"Open") → 3

COUNTIF questions

Is COUNTIF case-sensitive?

No. "open", "Open" and "OPEN" all match the same cells.

How do I count cells that contain a word?

Use wildcards: =COUNTIF(B2:B7,"*late*") counts cells that contain late anywhere in the text.

How do I count with two conditions?

Use COUNTIFS: =COUNTIFS(B2:B7,"Open",C2:C7,">4") counts open tickets that took more than 4 hours.

How do I count empty cells?

=COUNTIF(B2:B7,"") counts blank cells, and =COUNTIF(B2:B7,"<>") counts cells that aren't blank.

Related functions

Reading is the warm-up

The reps are what make it stick. Try COUNTIF in the practice sheet above.

Practise COUNTIF ↑