Count cells with text, numbers or blanks in Excel
To count the cells in C2:C21 that have text in them, use =COUNTIF(C2:C21,"*"), or take the numbers away from everything: =COUNTA(C2:C21)-COUNT(C2:C21). COUNTA counts anything that isn't empty, COUNT counts numbers, and COUNTBLANK counts the empty cells. They all work in every version of Excel, on Windows and Mac and in Excel for the web.
Counting cells at a glance
| You want to count | Formula | Notes |
|---|---|---|
| Cells with any text | =COUNTIF(B2:B11,"*") | Numbers and empty cells are left out; use "?*" to skip formulas that show nothing |
| The same, another way | =COUNTA(B2:B11)-COUNT(B2:B11) | Everything, take away the numbers |
| Cells that contain a word | =COUNTIF(B2:B11,"*late*") | Capitals don't matter |
| Cells with a number | =COUNT(B2:B11) | Dates count as numbers |
| Cells that aren't empty | =COUNTA(B2:B11) | Or =COUNTIF(B2:B11,"<>") |
| Empty cells | =COUNTBLANK(B2:B11) | Also counts formulas that show nothing |
| Text in one group only | =COUNTIFS(A2:A11,"Sales",B2:B11,"*") | A pair for each condition |
Each one is worked through below.
A worked example
Ten people were asked to rate an away day out of 10. Five gave a number, two wrote something instead (n/a, not sure) and three left it empty.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Name | Rating | Counting | Answer | |
| 2 | Amira | 8 | Anything (COUNTA) | 7 | |
| 3 | Ben | n/a | Numbers (COUNT) | 5 | |
| 4 | Cara | 6 | Text (COUNTA − COUNT) | 2 | |
| 5 | Dev | Text (COUNTIF "*") | 2 | ||
| 6 | Ewa | 9 | Empty (COUNTBLANK) | 3 | |
| 7 | Finn | not sure | |||
| 8 | Gita | 7 | |||
| 9 | Hana | ||||
| 10 | Ivan | 5 | |||
| 11 | Jo |
- Anything: 5 numbers and 2 bits of text is 7 cells with something in.
=COUNTA(B2:B11)gives 7. - Numbers:
=COUNT(B2:B11)gives 5. COUNT skips text. - Text: 7 − 5 = 2. That's
=COUNTA(B2:B11)-COUNT(B2:B11). - Empty:
=COUNTBLANK(B2:B11)gives 3.
Text only: COUNTIF with *
In COUNTIF, * means "any text". So =COUNTIF(B2:B11,"*") counts the cells with text in them and skips numbers and empty cells. It gives 2, the same as COUNTA minus COUNT. A number never matches "*", even a long one.
Cells that contain a word
Put words round the * to count cells that contain them. Here are the comments from the same away day. Which ones mention "late"? Lunch was late, Started late and Late finish: 3. Capitals don't matter, so "Late" counts. "late*" with no star in front only finds cells that start with late, so it gives 1.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Name | Comment | Count the comments that | Count | |
| 2 | Amira | Room too cold | have any text | 7 | |
| 3 | Ben | Lunch was late | contain late | 3 | |
| 4 | Cara | Great day | contain cold | 2 | |
| 5 | Dev | start with late | 1 | ||
| 6 | Ewa | Started late | |||
| 7 | Finn | Too cold by 3pm | |||
| 8 | Gita | Late finish | |||
| 9 | Hana | Good speaker |
Watch for words inside other words: "*late*" would also count "chocolate". To use a word typed in a cell, such as H1, join the stars on: =COUNTIF(B2:B9,"*"&H1&"*"). To mark each matching row with a word or a tick, see if a cell contains text.
Cells that aren't empty, and response rates
COUNTA is the quickest way to count cells with anything in them, and =COUNTIF(B2:B11,"<>") does the same thing. A response rate is the people who answered divided by everyone. In the worked example, 7 of the 10 answered, so 7 ÷ 10 = 70%.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Name | Rating | |||
| 2 | Amira | 8 | Answered | 7 | |
| 3 | Ben | n/a | Asked | 10 | |
| 4 | Cara | 6 | Response rate | 70% | |
| 5 | Dev | ||||
| 6 | Ewa | 9 | |||
| 7 | Finn | not sure | |||
| 8 | Gita | 7 | |||
| 9 | Hana | ||||
| 10 | Ivan | 5 | |||
| 11 | Jo |
Cells that only look empty
A formula that shows nothing, such as =IF(B2="","",B2*10), leaves a cell that looks empty. COUNTA still counts it, because the cell holds a formula. COUNTBLANK counts it as empty too, so the two can add up to more than the number of cells. Here, 5 cells give a COUNTA of 5 and a COUNTBLANK of 2.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Name | Rating | Points | Counting | Answer | |
| 2 | Amira | 8 | 80 | COUNTA | 5 | |
| 3 | Ben | COUNTBLANK | 2 | |||
| 4 | Cara | 6 | 60 | COUNT | 3 | |
| 5 | Dev | 7 | 70 | Not showing empty | 3 | |
| 6 | Ewa |
To count only the cells that show something, use =SUMPRODUCT(--(C2:C6<>"")). C2:C6<>"" is TRUE for each cell that isn't showing empty, the -- turns TRUE into 1, and SUMPRODUCT adds them: 3. COUNTIF with "*" counts those cells as text too, while "?*" needs at least one character, so it skips them. A cell with only a space in it also looks empty but counts in COUNTA. Click the cell and look in the formula bar to see what's there.
Text in one group only
COUNTIFS adds a condition. To count the text answers from the Sales team only, pair the Team column with "Sales" and the Rating column with "*". In this list, Sales has 4 people, and 2 of them wrote text.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Name | Team | Rating | Count | Answer | |
| 2 | Amira | Sales | 8 | Sales, text | 2 | |
| 3 | Ben | Sales | n/a | Sales, numbers | 2 | |
| 4 | Cara | Support | 6 | Support, empty | 2 | |
| 5 | Dev | Sales | not sure | |||
| 6 | Ewa | Support | ||||
| 7 | Finn | Sales | 7 | |||
| 8 | Gita | Support | ? | |||
| 9 | Hana | Support |
There's no "is a number" condition, so ">=0" counts the numbers of 0 or more. More on conditions in COUNTIF and COUNTIFS.
Common mistakes
COUNT gives 0 on a list of names
COUNT only counts numbers. For names and other text, use COUNTA.
COUNTA is one too high
A cell that looks empty might have a space in it, or a formula that shows nothing. COUNTA counts both, as above.
Numbers counted as text
Numbers pasted from another system are sometimes stored as text, so COUNT skips them and the text count is too high. Usually they sit on the left of the cell, with a green triangle in the corner. See numbers stored as text.
Counting the heading
=COUNTA(B:B) on the whole column counts the heading in B1 too. Start the range on row 2, or take 1 away.
Counting different values
COUNTA counts every filled cell, so a name listed three times counts 3 times. To count each name once, see counting unique values.
Try it now
In H1, count how many people wrote text in column C instead of giving a number.
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | Employee | Coming to the away day? | Rating out of 10 | Wrote text | ||||
| 2 | Chen | Yes | 4 | |||||
| 3 | Rachel | Maybe | not sure | |||||
| 4 | Sunil | Yes | not sure | |||||
| 5 | Ben | No | 2 | |||||
| 6 | Alex | No | n/a | |||||
| 7 | Grace | Yes | 8 | |||||
| 8 | Nia | |||||||
| 9 | Tom | Yes | 9 | |||||
| 10 | Ella | Maybe | ? | |||||
| 11 | Owen | No | 7 | |||||
| 12 | Priya | Yes | ||||||
| 13 | Will | Maybe | 6 | |||||
| 14 | Lucy | No | n/a | |||||
| 15 | Dev | Yes | 10 | |||||
| 16 | Hana | |||||||
| 17 | Sam | Yes | 5 | |||||
| 18 | Femi | Maybe | depends | |||||
| 19 | Kerry | No | 3 | |||||
| 20 | Zoe | Yes | 7 | |||||
| 21 | Ivan |
Open this in Try a formula: the same sheet with the answer filled in, to change or share by link.
Part of IF and COUNTIF practice: every lesson on the topic, with a project in Excel.
Where it works
COUNT, COUNTA, COUNTBLANK and COUNTIF work in every version of Excel, on Windows and Mac, and in Excel for the web. COUNTIFS needs Excel 2007 or later.
Questions
How do I count cells that contain any text in Excel?
Use =COUNTIF(B2:B50,"*"). The star stands for any text, so every cell with text in it is counted, and numbers, dates and empty cells are left out. =COUNTA(B2:B50)-COUNT(B2:B50) gives the same answer by counting everything and taking away the numbers.
How do I count cells that contain specific text?
Put stars either side of the word: =COUNTIF(B2:B50,"*late*") counts every cell with "late" anywhere in it, in capitals or not. Leave out the first star to count cells that start with the word, or the last one for cells that end with it. Without any stars, COUNTIF only counts cells that hold exactly that word and nothing else.
How do I count cells that are not blank?
Use =COUNTA(B2:B50), which counts every cell with something in it: text, numbers, dates and formulas. =COUNTIF(B2:B50,"<>") does the same. Both count a formula that shows nothing, because the cell isn't really empty. To count only the cells that show something, use =SUMPRODUCT(--(B2:B50<>"")).
Why does COUNTA count cells that look empty?
Something is in them that you can't see. Usually it's a formula that shows nothing, such as =IF(A2="","",A2), a space typed by mistake, or an empty text value left behind by pasting. Click the cell and look in the formula bar. Clear the cells that should be empty, or count with =SUMPRODUCT(--(B2:B50<>"")), which skips cells that show nothing.