Excel Word Count: Beyond SUBSTITUTE

You might want to count the number of words in a cell in Excel as part of data validation or conditional formatting. If you are a content creator using Excel for keyword count, you might also be interested in counting the words as part of your workflow.

For counting words in a cell in Excel, you can use two types of formulas. One is a workaround that works with all versions of Excel, and the other is a genuine word count formula, which requires Excel 365.

Can we use them in cell ranges as well? Yes, certainly.

Word Count Using a Workaround in Excel

You should follow this Excel word count formula if you are not using Excel for Microsoft 365.

Generic Formula:

=IF(cell<>"", LEN(TRIM(cell))-LEN(SUBSTITUTE(cell," ",""))+1,"")

For counting the number of words in the text in cell A1, you can use the following formula in cell B1:

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

How does this formula work?

Formula Breakdown:

Let’s assume the text in cell A1 is ” Fresh Mango Juice “, which contains three words: “Fresh,” “Mango,” and “Juice.” It contains leading, trailing, and extra spaces, though.

Part 1:

LEN(TRIM(A1))

This will return 17, the length of the string in cell A1 after removing leading, trailing, and extra spaces.

  • TRIM(cell) removes leading, trailing, and repeated spaces in the text in the specified cell.
  • LEN function returns the length of the string.
Length of the string in cell A1 after applying TRIM in Excel

Part 2:

LEN(SUBSTITUTE(A1," ",""))

This will return 15, i.e., the length of the string after removing all spaces.

  • SUBSTITUTE(A1," ","") replaces all spaces with null.
  • LEN function returns the length of the string.
Length of the string after removing all spaces

Excel Word Count:

Part 1 - Part 2

This returns the number of spaces in the text. We need to add 1 to this count to get the word count in that cell.

The role of =IF(A1<>"", ... ,"") is to return a blank value if the cell doesn’t contain any value.

The Genuine Word Count Formula in Excel

If you are using Excel for Microsoft 365, you can use the following formula, though the above workaround works.

Generic Formula:

=IF(cell<>"", COUNTA(TEXTSPLIT(cell," ",,TRUE)),"")

If you want to find the word count in cell A1, apply the following formula to cell B1:

=IF(A1<>"", COUNTA(TEXTSPLIT(A1," ",,TRUE)),"")

Why do we call this the genuine word count formula in Excel?

The TEXTSPLIT function splits the provided text string by using a column delimiter that is ” “. The COUNTA function counts those words.

Excel Word Count Using COUNTA and TEXTSPLIT Functions

Similar to our workaround formula, the purpose of =IF(A1<>"", … ,"") is to return a blank value if the cell doesn’t contain any value.

Counting Number of Words in a Range in Excel

The above single-cell word count is usually useful in data validation and conditional formatting in Excel.

For those who are content creators, you may want to count the words in a column or multiple columns all at once.

Single Column:

Assume you want to count the words in A1:A100 in your Excel spreadsheet. If you are not using Excel in Microsoft 365, you can use my workaround formula.

In cell B1, enter the following formula:

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

Drag the fill handle in the bottom right corner of cell B1 (it appears only when the cell is selected) down to cell B100.

In cell C1, enter the following formula to total the number of words:

=SUM(B1:B100)

If you are using Excel for Microsoft 365, you are lucky to use the Lambda functions.

Simply enter this formula in cell B1:

=SUM(MAP(A1:A100,LAMBDA(val,IF(val<>"",COUNTA(TEXTSPLIT(val," ",,TRUE)),""))))
Dynamic array formula counting words in a column in Excel

Two Column:

The above two formulas are flexible enough to count words in multiple columns in an Excel spreadsheet, both in newer and older versions.

For data in columns A and B, you can use the following formulas.

Drag Down Formula:

Apply this formula in cell C1 and drag it down as far as needed, then sum the results in cell D1:

=IF(A1&B1<>"", LEN(TRIM(A1&" "&B1))-LEN(SUBSTITUTE(A1&" "&B1," ",""))+1,"")

Dynamic Array Formula:

As before, simply enter this formula in cell C1:

=SUM(MAP(A1:B100,LAMBDA(val,IF(val<>"",COUNTA(TEXTSPLIT(val," ",,TRUE)),""))))

Resources

Here are a few related resources:

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Calculate Trip Days by Month (Start, End, and Full Days) in Google Sheets

If you're managing business travel in Google Sheets, you may need to calculate how...

Mode of Comma-Separated Numbers in Excel (Dynamic Array)

There is no dedicated function in Excel to directly find the mode of comma-separated...

How to Find Mode of Comma-Separated Numbers in Google Sheets

Working with comma-separated numbers inside a single cell is a common scenario in Google...

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

More like this

Mode of Comma-Separated Numbers in Excel (Dynamic Array)

There is no dedicated function in Excel to directly find the mode of comma-separated...

Sort Each Row Individually in Excel Using a LAMBDA Formula

Sorting rows in Excel typically refers to rearranging entire datasets based on values in...

Sort by Field Labels Using the SORT and XMATCH Combo in Excel

Want to sort your Excel data by column names instead of column positions? Learn...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.