formulastreak

How to count cells with text in Excel

Updated · Checked on a live sheet · Excel and Google Sheets

The formula

To count cells with text in Excel, use =COUNTIF(range, "*"): for example =COUNTIF(E2:E7, "*") counts the cells in E2:E7 that contain text. The asterisk is a wildcard for “any characters”, which only text matches, so numbers and empty cells aren't counted. Microsoft's COUNTIF page uses the same example.

In general: =COUNTIF(range, "*")

Try it on a live sheet

Four campaigns have an owner; the other two cells are empty · edit H1 and watch it recalculate
Click a cell (or use the arrow keys) to insert its address · Enter shows the resultH1 = 4
ABCDEFGH
1CampaignClicksSalesConversionOwnerWith an owner4
2Spring email120036Mara
3Instagram86012
4Display ads00Jonas
5Search ads230069Priya
6Newsletter54027
7Partner blog00Kenji

H1 shows 4: Mara, Jonas, Priya and Kenji. The two campaigns without an owner are skipped.

Why it works

Counts the cells in E2:E7 whose value matches the pattern "*" (* stands for any text, ? for one character).

  1. 1. COUNTIF: Counts the cells in E2:E7 whose value matches the pattern "*" (* stands for any text, ? for one character).

Every non-empty cell: COUNTA

COUNTA(E2:E7) counts every cell that isn't empty, text and numbers alike. Use it when you want “filled in”, and COUNTIF with "*" when you want text only.

=COUNTA(E2:E7)

Text containing a word

Put the word between asterisks: COUNTIF(A2:A7, "*ads*") counts the campaigns with “ads” anywhere in the name.

=COUNTIF(A2:A7,"*ads*")

Numbers stored as text

To find how many entries in a number column are really text (and will be skipped by SUM), count the text cells in that column: COUNTIF(C2:C11, "*"). Anything above 0 is worth a look before you total the column.

=COUNTIF(C2:C11,"*")

When you need it

Counting text cells helps you audit data: how many rows have a comment, how many records have an owner, how many “numbers” in a column are actually text and will be skipped by SUM. That last use catches imports that look right but don't add up. Compare COUNTIF with "*" against COUNTA and COUNT on the same range: if COUNT plus the text count doesn't equal COUNTA, something unexpected is in there.

In Google Sheets

Google Sheets' COUNTIF supports the same * and ? wildcards, so these formulas work there unchanged.

Common mistakes

  • Using COUNT, which counts only numbers, to count names.

  • Cells that look empty but hold a space or an empty string from a formula: COUNTIF with "*" may count them.

  • Expecting "*" to count numbers stored as text as numbers: they're text, so they're counted.

Practise COUNTIF on a live sheet

Lesson 7, COUNT and COUNTA (Unit 2, Ranges and functions), has 3 graded exercises, checked instantly, with steps and hints when you're stuck.