Excel Supreme

Excel track · Exercise 16 of 86

COUNTIF: count one condition

Count the rows that meet one condition, and get the edges of the range right.

Beginner

Support ticket log

Read-only data · screen 1 of 3 · answer in B10

In B10, count how many tickets have the status "Open".

AB
1TicketStatus
2T-1001Open
3T-1002Closed
4T-1003Open
5T-1004Pending
6T-1005Open
7T-1006Closed
8T-1007Open
9T-1008Escalated
10Open tickets

Download this grid (.xlsx) Two tabs: the grid you see, and the answer.

B10

What it does

COUNTIF reads a range and counts the cells that meet one condition. Text criteria go in quotes, so =COUNTIF(B2:B9,"Open") returns 4: four of the eight statuses read Open. A number needs no quotes, while ">=5" and "<>Closed" keep theirs because a comparison is still text.

This sheet holds eight tickets with four different statuses, and the answer sits under the last of them. The range has to reach B9. Stop at B8 and the count comes back as 3, one short, and the ticket you missed is not marked.

Case does not matter, so "open" and "Open" land in the same count. Wildcards work inside the criteria as well: "O*" also returns 4 here, and "T-10*" tested against column A would count all eight tickets.

Syntax

=COUNTIF(range, criteria)

Worked example

On Support ticket log, =COUNTIF(B2:B9,"Open") returns 4.

=COUNTIF(B2:B9,"Open")

Common errors

Error codes for COUNTIF
ErrorWhat it means and how to fix it
#NAME?An unquoted criterion such as COUNTIF(B2:B9,Open) sends Excel looking for a name called Open, and there is none.
One shortA range that stops at B8 counts three Open tickets and reports nothing wrong.
#REF!The range points at cells that have been deleted since, so there is nothing left to count.

At work

Support queues and stock rooms run on this count: how many tickets are open, how many lines are short. It is just as often tallied by eye, one screen at a time.