How to Count Cells With Text in Excel
By ExcelReady TeamUpdated 6 min read
The short answer
To count cells that contain text in Excel, use COUNTIF with an asterisk: =COUNTIF(B2:B8,"*"). The * wildcard matches any text, so numbers, dates and blank cells are not counted. COUNTA is different: it counts every cell that isn't empty, numbers included. To count one specific word, put it in quotes: =COUNTIF(B2:B8,"Yes").
Key takeaways
- =COUNTIF(range,"*") counts text cells and skips numbers, dates, logical values and blanks.
- COUNTA counts every non-empty cell, so it includes numbers; COUNTA minus COUNT is a rough text count.
- "?*" counts cells with at least one character, which leaves out empty text from formulas.
- Numbers stored as text and cells holding only a space are counted as text.
- For a specific word use =COUNTIF(range,"word"), and for partial matches use "word".
On this page+
To count cells with text in Excel, use =COUNTIF(range,"*"). The asterisk is a wildcard that matches any text, so the formula counts words and skips numbers, dates and empty cells. This guide compares it with COUNTA and ISTEXT, shows how to count a specific word, and explains the cells that look empty but still count.
The sample data#
Every example uses this survey column in A1:B8. It mixes words, numbers and one blank cell, which is exactly where the different counting functions disagree:
| A | B | |
|---|---|---|
| 1 | Respondent | Answer |
| 2 | R1 | Yes |
| 3 | R2 | 42 |
| 4 | R3 | |
| 5 | R4 | No |
| 6 | R5 | N/A |
| 7 | R6 | 15 |
| 8 | R7 | Maybe |
There are seven answer cells: four hold text (Yes, No, N/A, Maybe), two hold numbers (42 and 15) and one is blank. "N/A" here is typed text, not the #N/A error.
How to count cells with any text#
Use COUNTIF with a single asterisk as the criteria. COUNTIF counts the cells in a range that match a condition, and "*" means "any text, of any length":
=COUNTIF(B2:B8,"*")- Click an empty cell, such as D2.
- Type
=COUNTIF(B2:B8,"*"). - Press Enter.
The result is 4. The numbers 42 and 15 are left out because wildcards only match text, and the blank cell is left out because it holds nothing. Dates are numbers in Excel, so they are skipped too, and so are the logical values TRUE and FALSE. For the basics of COUNTIF, see how to use COUNTIF or the COUNTIF function guide.
COUNTA, COUNT and COUNTIF compared#
Excel has several counting functions, and each one answers a different question. On the same column:
| Formula | What it counts | Result |
|---|---|---|
=COUNTIF(B2:B8,"*") | Text cells | 4 |
=COUNTA(B2:B8) | Every non-empty cell | 6 |
=COUNT(B2:B8) | Numbers and dates | 2 |
=COUNTBLANK(B2:B8) | Empty cells | 1 |
=COUNTA(B2:B8)-COUNT(B2:B8) | Non-empty cells that aren't numbers | 4 |
COUNTA is the one people often reach for by mistake. It counts anything that isn't empty, so it includes the two numbers and gives 6. Use it when you want "how many answers were given", and COUNTIF with "*" when you want "how many answers were words". The COUNTA function guide and the lesson on COUNT and COUNTA cover the differences in more depth.
COUNTA - COUNT gives the same 4 here, but it also counts errors and TRUE/FALSE values, so it is only a rough text count. COUNTIF with "*" is more precise.
How to count cells with specific text#
To count one particular word, put it in quotes as the criteria:
| Question | Formula | Result |
|---|---|---|
| Answered Yes | =COUNTIF(B2:B8,"Yes") | 1 |
| Answered No | =COUNTIF(B2:B8,"No") | 1 |
| Text other than N/A | =COUNTIF(B2:B8,"*")-COUNTIF(B2:B8,"N/A") | 3 |
| Contains the letter a | =COUNTIF(B2:B8,"*a*") | 2 |
COUNTIF ignores capitals, so "yes" and "YES" match "Yes". The pattern "*a*" finds N/A and Maybe, because each contains an a somewhere. Partial matches are covered in COUNTIF contains text, and counting yes/no answers in how to count Yes, No and ticks.
Cells that look empty but count as text#
Two kinds of cell look blank but still count as text:
- A cell holding a space. A stray space typed by mistake is text, so
"*"counts it. Select the cell and look at the formula bar, or check its length with=LEN(B4). A result of 1 or more means something is there. - A formula that returns empty text. A formula such as
=IF(A2="","",A2)shows nothing when A2 is empty, but the cell holds empty text (""). COUNTIF with"*"and ISTEXT can count these cells too.
To skip empty text, use "?*" instead. The ? wildcard means exactly one character, so "?*" means "at least one character":
=COUNTIF(B2:B8,"?*")On the sample data it also returns 4, because none of the cells holds empty text. On a sheet full of formulas, the two counts can differ. To find cells that are truly empty versus filled, see COUNTIF not blank.
Counting text with ISTEXT and SUMPRODUCT#
ISTEXT returns TRUE when a cell holds text and FALSE otherwise. Combined with SUMPRODUCT, it gives a text count without wildcards:
=SUMPRODUCT(--ISTEXT(B2:B8))ISTEXT checks each cell, -- turns TRUE and FALSE into 1 and 0, and SUMPRODUCT adds them up. The result is 4. This form is useful when you want to combine the text test with another condition, such as =SUMPRODUCT(ISTEXT(B2:B8)*(A2:A8<>"R7")), which returns 3.
Numbers stored as text#
A number typed with an apostrophe, like '42, or imported from another system can be stored as text. Excel then counts it as text, not as a number. The cell usually sits on the left side of the column and may show a small green triangle in the corner.
That changes your counts: COUNTIF with "*" goes up, COUNT goes down, and SUM ignores the value. If a text count seems too high, look for numbers stored as text and convert them with VALUE or the Convert to Number option on the warning icon.
When your next question is how many different values a column holds, or how many repeat, read how to count unique values and how to count duplicates.
How to count text cells that meet another condition#
To count text cells in one group only, use COUNTIFS with "*" as one of the criteria. If column C held each respondent's region, this would count the North respondents who gave a text answer:
=COUNTIFS(B2:B8,"*",C2:C8,"North")A row counts only when both conditions are TRUE. Another common job is counting text answers for every question in a survey, one column per question. Put =COUNTIF(B$2:B$8,"*") under the first question and fill it right (Windows: Ctrl+R; Mac: ⌘R). The $ before each row number keeps rows 2 to 8 fixed while the column letter changes to C, D and so on.
Practise it#
Choosing the right counting function is a classic screening-test question. Practise COUNTIF in a live spreadsheet, including wildcards, and then compare it with COUNT and COUNTA in the COUNT and COUNTA lesson. Each lesson checks your formula instantly.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
The Answer column mixes words, numbers and a blank. In D2, use COUNTIF with a wildcard to count only the cells in B2:B8 that contain text.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Answer | ||||
| 2 | Text cells | ||||
| 3 | |||||
| 4 | R3 | ||||
| 5 | No | ||||
| 6 | N/A | ||||
| 7 | |||||
| 8 | Maybe | ||||
| 9 | |||||
| 10 | |||||
| 11 |
Tip: The criteria is a single asterisk in double quotes. It matches any text.
Practise this in a lesson
Frequently asked questions
How do I count cells with any text in Excel?
Use =COUNTIF(B2:B8,"*"). The asterisk matches any text, so the formula counts every text cell and skips numbers, dates and blank cells.
What is the difference between COUNTA and COUNTIF with an asterisk?
COUNTA counts every cell that isn't empty, including numbers, dates and errors. COUNTIF with "*" counts only cells that hold text.
How do I count cells with specific text?
Put the text in double quotes as the criteria: =COUNTIF(B2:B8,"Yes"). COUNTIF ignores capitals, so yes and YES count too. Use "Yes" to count cells that contain the word anywhere.
Why does my text count include cells that look empty?
Those cells probably hold a space or a formula that returns empty text (""). Both count as text. Use "?" instead of "" to skip empty text, and clean stray spaces with TRIM.
How do I count cells that are not text?
Use COUNT for numbers and dates: =COUNT(B2:B8). To count every non-empty cell that is not text, subtract: =COUNTA(B2:B8)-COUNTIF(B2:B8,"*").