30 Advanced Excel Tips for 2026

Excel Champs / Excel Formulas List / How to Count Words in Excel (Formula)
By Puneet Gogia (Microsoft MVP)

How to Count Words in Excel (Formula)

30+ Advanced Excel Tips for 2026

No spam. Only Excel Stuff. God Promise. 😊

Excel has no word-count feature, so you count the spaces and add one: =LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))+1. TRIM is the part that matters — without it, a trailing space or a double space between words inflates the count, which is the most common reason this formula gives the wrong answer.

For a whole range, wrap it in SUMPRODUCT: =SUMPRODUCT(LEN(TRIM(A1:A11))-LEN(SUBSTITUTE(TRIM(A1:A11)," ",""))+1). Both return 1 for an empty cell, so guard it with IF when blanks are possible: =IF(A1="",0,LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))+1).

To count how many times a specific word appears rather than the total, use =SUMPRODUCT((LEN(D6:D9)-LEN(SUBSTITUTE(D6:D9,"Monday","")))/LEN("Monday")) — note that counts occurrences, not cells, so a cell containing “Monday” twice adds 2.

There is one option that I always wish Excel should have, and that is counting the number of words from a cell. If you work in MS Word, there is an inbuilt option on the status bar which shows you how many words there are in the document.

there is an option in word to count words but not in excel

But when it comes to Excel, there is no such option to count words. You can count the number of cells which have text but not actual words in them.

As you know, in Excel, we have functions, and you can use them to calculate almost everything. You can create a formula that can count words from a cell.

Today in this post, you will learn how to count words in Excel from a cell, a range of cells, or even the entire worksheet. And I’ll also show you how to count a specific word from a range of cells.

1. Count Words from a Single Cell

To count words from a cell, you need to combine the LEN function with the SUBSTITUTE function. And the formula will be (Text is in cell A1):

=LEN(A1)-LEN(SUBSTITUTE(A1," ",""))+1
formula to count word in excel using len substitute

When you refer to a cell using this formula, it will return 7 in the result. And yes, you have a total of 7 words in the cell.

How It Works

Before getting into this formula, just think this way. In a normal sentence, if you have eight words, then you will definitely have 7 spaces between those words. Right?

That means you will always have one word more than the spaces. The idea is simple: If you want to count the words, count the spaces and add one. To understand this formula, you need to split it into three parts.

how formula to count word in excel using len substitute works

In the first part, you used the LEN function to count the number of characters from cell A1. And in the second and third parts, you have combined SUBSTITUTE with LEN to remove spaces from the cell and then count the characters. At this point, you have an equation like this.

formula equation to count words in excel

That’s the total number of characters with spaces and the total number of characters without spaces. When you subtract the second number from the first, you get the number of spaces, and in the end, you add one to it. It returns 7 in the result, which is the total number of words in the cell.

Important: When you use the above formula, it will return 1 even if the cell is blank, so it’s better to wrap it with the IF function to avoid this problem.

=IF(ISBLANK(A2),0,LEN(A2)-LEN(SUBSTITUTE(A2," ",""))+1)

count words in excel use if when cell is blank

This formula will first check the cell and only return the word count if there is a value in the cell.

But both formulas above count every space, so extra spaces (two spaces between words, or spaces at the start or end) give you a wrong count. A cell with only spaces, or a formula that returns “”, isn’t blank for ISBLANK either. This version handles all of these by using TRIM, which removes the extra spaces before counting:

=IF(LEN(TRIM(A1))=0,0,LEN(TRIM(A1))-LEN(SUBSTITUTE(A1," ",""))+1)

For example, for ” two spaces here ” (with extra spaces), the first formula returns 8, while this one returns the right count, 3. And for an empty cell or a cell with only spaces, it returns 0.

2. Using a UDF

Apart from the above formulas, I have written a small code to create a UDF for this. This code will help you to create a custom function that will simply return the word count. In short, you don’t need to combine any functions.

Function MyWordCount(rng As Range) As Integer
MyWordCount = UBound(Split(rng.Value, " "), 1) + 1
End Function

Let me tell you how to use it.

  1. First of all, enter this code in a standard module in the VBA editor (Insert ➜ Module).
    add udf code to vbe to count words in excel cell
  2. And then come back to your worksheet, enter “=MyWordCount(” and refer to the cell in which you have the value.

And it will return the word count. This function splits the text at every space, so like the first formula, it counts extra spaces as extra words. Save the file as a macro-enabled workbook (.xlsm) to keep the function.

udf to count word in excel using len substitute

Related: Formula Bar in Excel

3. Count Words from a Range of Cells

Now let’s come to the next level. And here you need to count words from a range of cells instead of a single cell. The good news is that you just need to use the same formula (with a simple change) which you have used above. And the formula will be:

=SUMPRODUCT(LEN(A1:A11)-LEN(SUBSTITUTE(A1:A11," ",""))+1)

formula to count word in excel from column row range

In the above formula, A1:A11 is the range of cells, and when you enter the formula, it returns 77 in the result.

How It Works

This formula works in the same way as the first method, but with a small change. The only difference is you have wrapped it in SUMPRODUCT and referred to the entire range instead of a single cell.

how sumproduct works to count word in excel

Do you know that SUMPRODUCT can take arrays? So, when you use it, it returns an array where you have a count of words for each cell. And in the end, it sums those counts and tells you the count of words in the column.

There’s one catch: this formula adds 1 for every cell, so each blank cell in the range is counted as one word. If your range has blank cells or extra spaces, use this version, which counts only the cells with text and ignores the extra spaces:

=SUMPRODUCT((LEN(TRIM(A1:A11))>0)*(LEN(TRIM(A1:A11))-LEN(SUBSTITUTE(A1:A11," ",""))+1))

4. Word Count from the Entire Worksheet

This code is one of the useful macro codes which I use in my work, and it can help you to count all the words in a worksheet. It trims each cell first, so extra spaces don’t add to the count.

Sub Word_Count_Worksheet()
Dim WordCnt As Long
Dim rng As Range
Dim S As String
Dim N As Long
For Each rng In ActiveSheet.UsedRange.Cells
S = Application.WorksheetFunction.Trim(rng.Text)
N = 0
If S <> vbNullString Then
N = Len(S) - Len(Replace(S, " ", "")) + 1
End If
WordCnt = WordCnt + N
Next rng
MsgBox "There are total " & Format(WordCnt, "#,##0") & " words in the active worksheet"
End Sub

When you run it, it will show a message box with the number of words you have in the active worksheet.

vba code to count words in excel using vba

Related: What is VBA in Excel

5. Count a Specific Word/Text String from a Range

Here you have a different situation. Let’s say you need to count a specific word in a range of cells or check the number of times a value appears in a column.

Take this example: Below you have a range of four cells, and from this range, you need to count the occurrences of the word “Monday”.

For this, the formula is:

=SUMPRODUCT((LEN(D6:D9)-LEN(SUBSTITUTE(D6:D9,"Monday","")))/LEN("Monday"))
count words in excel specific with sumproduct formula

And when you enter it, it returns the count of the word “Monday”. That’s 4.

Important: It returns the count of the word (word’s frequency) from the range, not the count of the cells which have that word. Monday is there four times in three cells.

How It Works

To understand this formula, again you need to split it into four parts. In the first part, the LEN function returns an array of the count of characters from the cells.

use sumproduct formula to count a specific words from a range 1

The second part returns an array of the count of characters from the cells by removing the word “Monday”.

use sumproduct formula to count a specific words from a range 2

In the third part, the LEN function returns the number of characters in the word “Monday”.

use sumproduct formula to count a specific words from a range 3

After that, it subtracts part two from part one and then divides the result by part three, which returns an array with the count of the word “Monday” in each cell.

use sumproduct formula to count a specific words from a range 4

In the fourth part, SUMPRODUCT returns the sum of this array and gives the count of “Monday” in the range.

Keep in mind that SUBSTITUTE is case-sensitive, so this formula doesn’t count “monday” in lowercase. It also counts the word when it’s part of a longer word, like “Mondays”. To count the word in any case, convert the text to lowercase with LOWER and use the word in lowercase:

=SUMPRODUCT((LEN(D6:D9)-LEN(SUBSTITUTE(LOWER(D6:D9),"monday","")))/LEN("monday"))

Count Words with TEXTSPLIT in Microsoft 365

If you use Microsoft 365, you can also split the text into words with TEXTSPLIT and count them with COUNTA. TRIM removes the extra spaces first, and the IF part returns 0 for a blank cell:

=IF(TRIM(A1)="",0,COUNTA(TEXTSPLIT(TRIM(A1)," ")))

Conclusion

Whenever you are typing some text in a cell or a range of cells, you can use these methods to keep a check on the word count. I wish someday in the future Excel will get this option to count words. But, for the time being, you have all these awesome methods.

Which method do you like the most? 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 is my word count wrong?

Usually because of extra spaces. The basic formula counts every space, so two spaces between words or a space at the end adds a word. Use the TRIM version of the formula shown above.

Does the formula count words separated by line breaks?

No. The formula only looks at spaces. If you have line breaks in the cell (Alt + Enter), replace them with spaces first, by using SUBSTITUTE(A1,CHAR(10),” “) in place of A1.

How do I count the cells that contain a word?

Use COUNTIF with asterisks around the word. It counts each cell once, however many times the word appears in it, and it isn’t case-sensitive:

=COUNTIF(D6:D9,"*Monday*")
Puneet Gogia

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.

3M+ readers helped
1,000+ tutorials written
Since 2015 teaching Excel

19 thoughts on “How to Count Words in Excel (Formula)”

  1. To find out the count of specific word in an array I used SUM, it works.. Please tell me why you have used SUMPRODUCT?

    Reply
    • With SUMPRODUCT you don’t need to use an array formula.

      Reply
  2. Hello, thank you for your post, but how to count specific words from another excel sheet ( formula is in Sheet1 but words is in Sheet2)

    Reply
  3. Thanks a lot – this is great!
    To get a quote for a text translation (website text in excel file) I need the full word count per worksheet. Easy with your macro. 🙂

    Reply
  4. In the solutions above all is ok, if there is always just ONE space between words. However, if anywhere in the strings, there is more than one space between words then the result will be wrong. Therefore, the best is to add in the UDF a loop to substitute all two subsequent spaces by one space and repeat it until there is no change in a string length (so there was no substitution).

    Reply
  5. What if your cell contains the text “thisisagreatwebsite” (without the quotes, no capitals – all lowercase, and no spaces). How could I count those words?

    Reply
  6. Thank you for the formula! It’s a great use case for the LEN function!
    To avoid erroneous results in case of “unnecessary” blanks I would suggest to add TRIM:
    LEN(TRIM(A1))-LEN(SUBSTITUTE(A1,” “,””))+1
    Kind regards
    Katharina

    Reply

Leave a Comment