How to Count Cells with Text in Excel
To count cells with text in Excel, type =COUNTIF(A2:A100,"*") in an empty cell. If some cells hold formulas that return an empty string, use "?*" instead of "*", or the count comes out too high. We ran five popular formulas on the same eight cells in Excel, so you can see exactly what each one counts before you trust it.
Last updated: October 30, 2026
Quick Answer
To count cells with text in Excel, use =COUNTIF(A2:A100,"*"). The asterisk matches any text, so numbers, dates, TRUE/FALSE, errors and empty cells are left out. To also skip cells where a formula returned "" (they look empty), use =COUNTIF(A2:A100,"?*"), which needs at least one character.
At a glance
What Each Formula Actually Counts
Most guides list these formulas as if they were interchangeable. They aren't. We entered the eight kinds of cell you meet in real sheets into A2:A9 of a new workbook in Excel for Mac (version 16.108) on October 30, 2026, and ran each formula on that range. A tick means the cell was counted.
Swipe the table sideways to see all five formulas.
| Cell in A2:A9 and what we entered | COUNTIF "*" | COUNTIF "?*" | COUNTA | SUMPRODUCT ISTEXT | TRIM version |
|---|---|---|---|---|---|
| TextApple | ✓ | ✓ | ✓ | ✓ | ✓ |
| Number42 | ✓ | ✓ | |||
| Number stored as text'42 | ✓ | ✓ | ✓ | ✓ | ✓ |
| Formula that returns ""="" | ✓ | ✓ | ✓ | ||
| A single space(space) | ✓ | ✓ | ✓ | ✓ | |
| Error=NA() | ✓ | #N/A | |||
| Logical valueTRUE | ✓ | ✓ | |||
| Empty cell(nothing) | |||||
| Result for A2:A9 | 4 | 3 | 7 | 4 | #N/A |
The formulas, in column order: =COUNTIF(A2:A9,"*"), =COUNTIF(A2:A9,"?*"), =COUNTA(A2:A9), =SUMPRODUCT(--ISTEXT(A2:A9)) and =SUMPRODUCT(--(LEN(TRIM(A2:A9))>0)). To repeat the test, type the gray entries into A2:A9 exactly as shown.
What the test shows
- COUNTIF "*" and ISTEXT agreed on every cell. Both count numbers stored as text, single spaces and formula blanks.
- "?*" was the only text count that skipped the formula blank, which makes it the better default for sheets full of formulas.
- COUNTA is not a text count. It counted the number, TRUE and the error as well.
- The TRIM version counts numbers and TRUE too, and a single error anywhere in the range turns the whole result into #N/A.
Two more cells behaved in ways worth knowing. A cell holding only an apostrophe acted exactly like the formula blank: counted by "*", ISTEXT and COUNTA, skipped by "?*". A non-breaking space, which often arrives with data pasted from web pages, counted as text in all five formulas, including the TRIM one.
Method 1: COUNTIF With "*" or "?*"
COUNTIF is the quickest way, and it works the same in every current version of Excel. Wildcards only match text, which is what makes it work: a number or a date never matches "*".
- Click an empty cell. Click the cell where you want the answer, outside the range you are counting.
- Type the formula. Type =COUNTIF(A2:A100,"*") and change A2:A100 to your range. Start the range below the header row, or the header is counted too.
- Press Enter. Excel shows how many cells in the range contain text. Numbers, dates, TRUE/FALSE, errors and empty cells are not counted.
- Switch to "?*" if the count is too high. If some cells hold a formula that returns "" (they look empty), change "*" to "?*". That pattern needs at least one character, so those cells are skipped.
Any text
=COUNTIF(A2:A100,"*")Text with at least one character
=COUNTIF(A2:A100,"?*")Why the two differ: the asterisk matches zero or more characters (that is how Exceljet puts it), so an empty string from a formula still matches. The question mark stands for exactly one character, so "?*" reads as "one character, then anything". Microsoft's COUNTIF reference describes both wildcards and notes that criteria ignore upper and lower case.
Method 2: COUNTA, for Every Cell That Isn't Empty
COUNTA counts any cell with something in it: text, numbers, dates, TRUE/FALSE, errors, and formulas that return "". Microsoft's COUNTA page is explicit about that last one. Use it to see how many rows have anything filled in.
=COUNTA(A2:A100)COUNTBLANK is its mirror image, with one twist: it also counts cells that hold "". In our test sheet COUNTA returned 7 and COUNTBLANK returned 2, which adds up to 9 for eight cells, because the formula blank landed in both.
Method 3: SUMPRODUCT and ISTEXT
This gives the same count as COUNTIF "*" (see the table). ISTEXT returns TRUE for each text cell, the double minus turns TRUE and FALSE into 1 and 0, and SUMPRODUCT adds them up.
=SUMPRODUCT(--ISTEXT(A2:A100))It earns its place when you need a second condition. To count text cells in column A where column B says West:
=SUMPRODUCT(--ISTEXT(A2:A100),--(B2:B100="West"))COUNTIFS version, which also skips formula blanks: =COUNTIFS(A2:A100,"?*",B2:B100,"West")
In Excel for Microsoft 365, Excel 2021 and Excel 2024, =SUM(--ISTEXT(A2:A100)) works too. In Excel 2019 or older, a plain SUM needs Ctrl+Shift+Enter, so stick with SUMPRODUCT, which handles the range on its own.
Skip Cells That Only Contain Spaces
A cell with a space in it looks empty but counts as text in every COUNTIF and ISTEXT formula. To skip it, let TRIM strip the spaces and count only the text cells that have something left:
=SUMPRODUCT(ISTEXT(A2:A100)*(LEN(TRIM(A2:A100))>0))In our test, TRIM formulas like this one returned #N/A as soon as the range held an error. If yours might, wrap the range in IFERROR (in Excel 2019 or older, confirm it with Ctrl+Shift+Enter):
=SUM(ISTEXT(A2:A100)*(LEN(TRIM(IFERROR(A2:A100,"")))>0))Pasted web data: use UNICHAR(160), not CHAR(160)
Text copied from web pages often carries non-breaking spaces, and TRIM only removes the normal space (character 32). The usual fix swaps them for normal spaces first:
=SUM(ISTEXT(A2:A100)*(LEN(TRIM(SUBSTITUTE(IFERROR(A2:A100,""),UNICHAR(160)," ")))>0))
The version you usually see online uses CHAR(160). That works on Windows, but on a Mac CHAR uses the Macintosh character set. In our test, =CHAR(160) returned a dagger (†) in Excel for Mac and the CHAR version silently counted the non-breaking space anyway. UNICHAR(160) worked.
Count Cells With Specific Text
Put the text in quotes to count the cells that match it exactly. COUNTIF ignores case, so in our test "Pending" matched Pending, pending and PENDING, but not "Pending " with a trailing space.
Exactly Pending (any case)
=COUNTIF(B2:B100,"Pending")Whatever is typed in E1
=COUNTIF(B2:B100,E1)Pending or Done, added together
=SUM(COUNTIF(B2:B100,{"Pending","Done"}))Exactly Pending, case-sensitive
=SUMPRODUCT(--EXACT(B2:B100,"Pending"))One surprise from the test: =COUNTIF(A2:A9,"42") returned 2. It matched both the number 42 and the text '42, so COUNTIF can't tell the two apart. If your statuses come from a drop-down list, the spelling is always the same and exact matches are safe.
Count Cells That Contain a Word
Wildcards let COUNTIF match part of a cell. There are three:
| Wildcard | Matches | Example |
|---|---|---|
| * | Any number of characters, including none | "*pend*" finds Not pending |
| ? | Exactly one character | "c?t" finds cat and cut |
| ~ | Makes the next * or ? an ordinary character | "*~?*" finds Done? |
Contains pending anywhere
=COUNTIF(B2:B100,"*pending*")Starts with pending
=COUNTIF(B2:B100,"pending*")Ends with ing
=COUNTIF(B2:B100,"*ing")Contains whatever is in E1
=COUNTIF(B2:B100,"*"&E1&"*")Does not contain pending
=COUNTIF(B2:B100,"<>*pending*")Empty cells count as not containing it, so keep the range to your data.
Contains Pending, case-sensitive
=SUMPRODUCT(--ISNUMBER(FIND("Pending",B2:B100)))To count cells that don't hold text at all (numbers, errors, TRUE/FALSE and empty cells), flip the test: =COUNTIF(A2:A9,"<>*"). On our eight test cells it returned 4: the number, the error, TRUE and the empty cell.
Count Text Cells in a Filtered List
COUNTIF counts hidden rows too. To count only the text cells you can see after filtering or hiding rows:
=SUMPRODUCT(SUBTOTAL(103,OFFSET(A2,ROW(A2:A100)-ROW(A2),0))*ISTEXT(A2:A100))SUBTOTAL(103, …) returns 1 for each visible cell that isn't empty and 0 for hidden ones, and ISTEXT keeps the text. When we hid one of the four text rows in our test sheet, the result went from 4 to 3. Change 103 to 3 if rows you hid by hand should still count; filtered-out rows are skipped either way, per Microsoft's SUBTOTAL rules.
Why Your Count Is Wrong
The count is too high
- Formula blanks. Cells with ="" or IF(…,"") look empty but hold text. Switch "*" to "?*".
- Spaces. A stray space makes a cell count. Use the TRIM formula above.
- The header row.
=COUNTIF(A:A,"?*")counted our Value header too. Start the range at row 2. - Numbers stored as text. They count as text. Excel flags them with a small green triangle; select them, click the warning icon and choose Convert to Number.
The count is too low
- Extra spaces in the data. "Pending " doesn't match "Pending". Match with "*Pending*" or clean the column with TRIM.
- The values are numbers. "*" never counts numbers or dates. Use COUNT for those, or COUNTA for everything.
- Hidden characters. Microsoft's COUNTIF page lists leading and trailing spaces, curly versus straight quotes and nonprinting characters as the usual culprits, and suggests CLEAN and TRIM.
COUNTIF returns #VALUE!
- Matching text longer than 255 characters. In our test, a 255-character criterion worked and a 256-character one returned #VALUE!. Microsoft suggests joining shorter pieces with &, but that failed too, since the joined text is still too long. This works for long text (it matched our 300-character test string):
=SUMPRODUCT(--(A2:A100=E1)). - A closed workbook. COUNTIF that refers to cells in another workbook returns #VALUE! when that workbook is closed. Open it.
Seeing the formula instead of a number? Show Formulas may be on. Press Ctrl+` (the grave accent key, left of 1 on a US keyboard) to switch back to results.
Frequently Asked Questions
What is the formula to count cells with text in Excel?
=COUNTIF(A2:A100,"*") counts the cells in A2:A100 that contain text. If some cells hold formulas that return "", use =COUNTIF(A2:A100,"?*") to skip them. Neither formula counts numbers, dates, TRUE/FALSE, errors or empty cells.
Why does COUNTIF count cells that look empty?
They hold empty text: a formula that returns "" or a lone apostrophe. The * wildcard matches zero characters, so "*" counts them. "?*" needs at least one character and skips them.
How do I count cells with specific text in Excel?
=COUNTIF(A2:A100,"Paid") counts cells that say exactly Paid, and =COUNTIF(A2:A100,"*paid*") counts cells that contain it anywhere. Both ignore case. For a case-sensitive count, use =SUMPRODUCT(--EXACT(A2:A100,"Paid")).
What is the difference between COUNT, COUNTA and COUNTIF?
COUNT counts numbers, dates included, since Excel stores dates as numbers. COUNTA counts every cell that isn't empty, including errors and formulas that return "". COUNTIF counts the cells that meet one condition, such as "*" for any text.
Does COUNTIF count cells with spaces?
Yes, with both "*" and "?*". To skip cells that hold only spaces, use =SUMPRODUCT(ISTEXT(A2:A100)*(LEN(TRIM(A2:A100))>0)).
Is COUNTIF case-sensitive?
No. Pending, pending and PENDING all match. Use =SUMPRODUCT(--EXACT(A2:A100,"Pending")) for an exact, case-sensitive match, or =SUMPRODUCT(--ISNUMBER(FIND("Pending",A2:A100))) for cells that contain the word with that capitalization.
How do I count cells that are not blank, ignoring formulas that return ""?
Use =ROWS(A2:A100)-COUNTBLANK(A2:A100). COUNTBLANK counts empty cells and cells holding "", so what is left is every cell with a value, numbers and errors included. A cell with only a space still counts.
Why does my COUNTIF formula return #VALUE!?
Either the text you are matching is longer than 255 characters (in our test, 256 was enough to break it) or the formula points at a workbook that is closed. Use =SUMPRODUCT(--(A2:A100=E1)) for long text, and open the other workbook.
Teaching Excel to your team?
Record your screen once with the Deckoholic Chrome extension and talk it through. It cuts the ums and pauses, adds zooms and captions, and gives you an MP4 or a step-by-step guide your team can follow.
Try Deckoholic Free