To count cells containing text, use =COUNTIF(A2:A20,"*"). The asterisk matches any sequence of characters, so it counts every cell holding text while skipping numbers, blanks, and errors.
If some cells hold only a space, they get counted as text — exclude them with =COUNTIFS(A2:A20,"*",A2:A20,"<> "). =SUMPRODUCT(--ISTEXT(A2:A20)) does the same job and is the more reliable of the two, because ISTEXT also catches numbers that were stored as text, which the asterisk method counts too but for a different reason.
To count a specific word instead of any text, use =COUNTIF(A2:A20,"John"), or =COUNTIF(A2:A20,"*John*") to match it anywhere inside the cell. For a case-sensitive count, COUNTIF won’t do it — use =SUMPRODUCT(--EXACT(A2:A20,"JOHN")), which counts “JOHN” while ignoring “john” and “John”.
Last week one of my readers asked me for a simple formula that he can use to count cells with text. Actually, he was trying to figure out which is the best method to use.
But think about it for a second. In Excel, you have different formulas to count all the cells where you have text values. The point is which one you should use.
I believe that it depends on the situation. One thing which you need to understand here is that cells with text mean all the cells where you don’t have numbers, logical values (TRUE/FALSE), blank cells, or errors.
Today in this post, I’d like to share 6 different ways to count cells with text in different situations.
1. COUNTIF with Wildcard Characters to Count Cells with Text Values
The best formula to count cells with text is COUNTIF with a wildcard character (* – Asterisk). In the below data table, you have a list of names and mobile numbers in a single column. And from this list, you need to count the number of cells with names (text). The formula will be:
=COUNTIF(A2:A20,"*")

When you enter it, it will return the count of the cells with text only.
Here’s How This Formula Works
Here we have used COUNTIF to count cells with specific criteria, and for the criteria, we have used an asterisk. When you use an asterisk, it will count cells with any number of characters, other than logical values, numbers (if they are not entered as text), and errors. Keep in mind that it also counts a cell with a formula that returns an empty text (“”), as that’s a text value with zero characters.
Note: If there are some cells where you just have a blank space, they will be counted as text. So for this, you can amend your formula like this:
=COUNTIFS(A2:A20,"*",A2:A20,"<> ")
This leaves out the cells with exactly one space. To leave out cells with any number of spaces and the cells with an empty text from formulas, use the following formula:
=SUMPRODUCT(ISTEXT(A2:A20)*(LEN(TRIM(A2:A20))>0))
2. SUMPRODUCT and ISTEXT to Count Number of Cells with Text
To count the number of cells with text in them, you can also create a formula by combining SUMPRODUCT and ISTEXT. And the formula will be:
=SUMPRODUCT(--ISTEXT(A2:A20))

When you enter it, it will return the number of cells that contain text.
Here’s How This Formula Works
To understand this formula, you need to split it into three different parts.
First, you have used ISTEXT to check if a cell contains text or not. Here ISTEXT returns an array where you have TRUE for the cells with text and FALSE for all other cells.

Second, you have added a double minus sign to convert the TRUE/FALSE array into 1/0. Now, for all the cells with the text, you have 1 and 0 for all others.

Third, you have used SUMPRODUCT to sum that array. And that sum is the number of cells that have text in them.

Using SUMPRODUCT here means you don’t need to enter your formula as an array formula.
Read Also – How to Count Colored Cells in Excel
3. Formula to Count Cells with Specific Text
Now, let’s dig deeper a little bit. Suppose you need to count the cells where you have a specific text. Here is an example. In the below data table, you need to count the cells where you have “John”. And for this, the formula will be:
=COUNTIF(A2:A20,"John")

This formula will return the number of cells that have the text you have specified. COUNTIF isn’t case-sensitive, so it also counts “JOHN” and “john”. To use the text from a cell, refer to the cell instead of typing the text, like D1 in place of “John”.
4. Cells with a Partial Text
Sometimes you need to count cells by matching a partial text. And, COUNTIF and wildcard characters can help you with this.
Check out the below table where we have the product name and invoice numbers combined. And from this, you need to count the number of cells with “Product-A”. Use the below formula:
=COUNTIF(A2:A20,"Product-A*")

This formula will return the number of cells that start with “Product-A”. If the text can be anywhere in the cell, put an asterisk on both sides:
=COUNTIF(A2:A20,"*Product-A*")
And to count the cells that don’t contain it, add the not equal operator: “<>*Product-A*”.
5. Case Sensitive Text
Now here is a different thing. You need to count the cells with a specific text and that should be a case-sensitive count.
From the below table, you need to count the cells with the name “JOHN”. Here you have the same name in lowercase letters as well, but the count should be only for capital letters.
For this, you can combine SUMPRODUCT with EXACT.
=SUMPRODUCT(--EXACT("JOHN",A1:A20))

It will return the number of cells where you have “JOHN”.
How this Formula Works
To understand this formula, you need to split it into three different parts.
First, you have used EXACT to compare the entire range of cells with the text “JOHN”. It returns an array where you have TRUE for the cells with “JOHN” and FALSE for “john”, “John”, and all other cells.

Second, you have added a double minus sign to convert that TRUE/FALSE array into 1/0. Now, for all the cells with the “JOHN”, you have 1 and 0 for all others.

Third, you have used SUMPRODUCT to sum that array. And that sum is the number of cells that have “JOHN” in them.

6. VBA to Count Cells with Text
Using a macro code is a big time saver. The below codes will help you to count the number of cells with text in the selection and in the entire worksheet.
For selection:
Sub countTextSelection() Dim rng As Range Dim i As Long For Each rng In Selection If Application.WorksheetFunction.IsText(rng) Then i = i + 1 End If Next rng MsgBox i End Sub
Entire Worksheet:
Sub countTextWorksheet() Dim rng As Range Dim i As Long For Each rng In ActiveSheet.UsedRange If Application.WorksheetFunction.IsText(rng) Then i = i + 1 End If Next rng MsgBox i End Sub
Related: What is VBA in Excel
Conclusion
I am sure all these methods are sufficient for you to count cells with text in any given situation. You can use any of the methods which you think are perfect for you.
For most situations, the first method is applicable without any problem. But if you want to be more specific, you can use the other methods. For me, VBA is a big time saver as I don’t have to apply formulas. Now it’s your time to tell me something.
Do you have any other method which we can use to count the number of cells with the text?
Make sure to share your views with me in the comment section, I’d love to hear from you. And please, don’t forget to share this post with your friends, I am sure they will appreciate it.
Frequently Asked Questions
Why does my count include cells that look empty?
Those cells have a space or a formula that returns “”. Both are text for COUNTIF with “*” and for ISTEXT. Use the SUMPRODUCT formula with LEN and TRIM from method 1 to leave them out.
Are numbers stored as text counted?
Yes. A number stored as text (with a green triangle in the corner, or entered with an apostrophe) is a text value, so all the formulas on this page count it.
Why does the SUMPRODUCT formula return an error?
The EXACT and LEN versions return an error if any cell in the range has an error, like #N/A. Fix the errors in the data first, or use COUNTIF, which simply skips them.
Written by
Puneet Gogia
Microsoft MVP — Excel · Founder, Excel Champs
Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.