Back to Excel learning resources

Excel COUNTIF: Count Cells Containing Text (with Practice)

Quick answer

Use =COUNTIF(B2:B7,"Pending") to count Pending statuses, for a result of 3.

Formula syntax

The syntax is =COUNTIF(range, criteria). Each part tells Excel what to check and what to return.

range
The cells Excel checks, such as the Status values in B2:B7.
criteria
The condition to match, such as the text "Pending" or a comparison like ">=10".

Worked example

This example counts how many rows have a Pending status.

Task statuses
TaskStatus
Order 1Pending
Order 2Done
Order 3Pending
Order 4Done
Order 5Pending
Order 6Done

Formula: =COUNTIF(B2:B7,"Pending")

Result: There are 3 cells with the status Pending.

How to type it in Excel

  1. Enter the headings "Task" and "Status" in A1:B1, then enter the six rows shown above in A2:B7.
  2. Select an empty cell for the count, such as D2.
  3. Type =COUNTIF(B2:B7,"Pending").
  4. Press Enter. Excel counts the matching status cells and returns 3.

Common mistakes

  • For text criteria, include double quotes. Use "Pending", not Pending.
  • Select only the status cells you want to count. COUNTIF uses one range and does not take a separate sum_range.
  • Check for extra spaces in source cells. "Pending " may not match "Pending".
  • Text matching is not case-sensitive. Use * for any number of characters or ? for one character, such as "Pend*".

Frequently asked questions

What does COUNTIF return?

COUNTIF returns the number of cells in one range that meet the condition.

Can COUNTIF count text?

Yes. COUNTIF can count text values, numbers, and cells that meet comparison conditions.

Can COUNTIF match part of a word?

Yes. Use a wildcard such as "*Pend*" to count cells containing that text.

Practice COUNTIF in a free interactive lesson