Excel has no WORDCOUNT function, but counting words is a classic trick: count the spaces between words and add one. LEN, SUBSTITUTE, and TRIM do it cleanly even with messy spacing.
The example
Word counts for a few phrases.
| A | B | |
|---|---|---|
| 1 | Phrase | Words |
| 2 | hello world | 2 |
| 3 | the quick brown fox | 4 |
| 4 | one | 1 |
The formula
The word count in B2:
How it works
Counting spaces is the whole idea:
TRIM(A2)first collapses runs of spaces to one and strips the ends, so messy input doesn’t over-count.LEN(TRIM(A2))is the length with single spaces;LEN(SUBSTITUTE(…, " ", ""))is the length with no spaces.- The difference equals the number of spaces between words.
- Words = spaces + 1, so add 1. “the quick brown fox” has 3 spaces →
4words.
An empty cell would return 1. Guard it: =IF(TRIM(A2)="", 0, LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2)," ",""))+1) so blanks count as 0 words.
Try it: interactive demo
Type a phrase (extra spaces are handled).
Variations
Guard against blank cells
Return 0 for empty input:
Count occurrences of a specific word
How many times “the” appears:
Count items in a comma list
Count commas + 1 instead of spaces:
Pitfalls & errors
Empty cell returns 1. With no words there are no spaces, so the +1 gives 1. Wrap in the IF guard shown above.
TRIM is essential. Without it, double spaces inflate the count. Always TRIM inside both LEN calls.
Punctuation isn’t a separator. “one,two” (no space) counts as one word. SUBSTITUTE punctuation to spaces first if needed.
Practice workbook
Frequently asked questions
How do I count words in a cell in Excel?
How do I make an empty cell return 0 words?
How do I count how many times a specific word appears?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class