Count Words in a Cell

Spreadsheets have no built-in word counter, but the number of words is one more than the number of spaces. Comparing a text's length with and without its spaces gives that count.

Free, no sign-up required · 5 free generations a day

Last updated

Describe your task, get the formula

Type what you need in plain English, or pick an example below. You get the formula, a step-by-step explanation, and a worked example.

Word count formulas

Syntax
=LEN(TRIM(A2)) - LEN(SUBSTITUTE(TRIM(A2), " ", "")) + 1
=IF(LEN(TRIM(A2))=0, 0, LEN(TRIM(A2)) - LEN(SUBSTITUTE(TRIM(A2), " ", "")) + 1)
=(LEN(A2) - LEN(SUBSTITUTE(LOWER(A2), "word", ""))) / LEN("word")

TRIM removes extra spaces so that double spaces are not counted twice. The second formula adds a guard for empty cells, which would otherwise return 1. The third counts how many times a given word appears.

Examples

Words in a single cell, safe for empty cells

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

Counts the spaces left after trimming, adds one, and returns 0 for an empty cell instead of 1.

Total words in a range

=SUMPRODUCT(LEN(TRIM(A2:A100))-LEN(SUBSTITUTE(TRIM(A2:A100)," ",""))+(LEN(TRIM(A2:A100))>0))

Applies the same logic to every cell in the range at once and adds the results. The last term adds one only for the cells that contain text.

How often a word appears in a cell

=(LEN(A2)-LEN(SUBSTITUTE(LOWER(A2),"error","")))/LEN("error")

Removes every occurrence of the word, measures how much shorter the text became, and divides by the word's length. LOWER makes the search case-insensitive.

Common mistakes and how to fix them

Empty cells count as one word

The space-counting formula returns 1 for an empty cell because it adds one. Add the IF(LEN(TRIM(A2))=0,0,…) guard.

The count is too high

Extra spaces, including non-breaking spaces copied from web pages, are counted as separators. TRIM removes ordinary spaces; replace non-breaking ones with SUBSTITUTE(A2,CHAR(160)," ").

Partial matches are counted as the word

Searching for the also finds it inside other and then, so those are counted too. To match whole words only, search for " the " with a space on each side, and add a space at the start and end of the text so words at the edges are found.

Frequently asked questions

Does this count words in other languages?

It works for any language that separates words with spaces. For languages that do not, such as Chinese or Japanese, there is no reliable space-based formula.

How do I count characters instead?

Use LEN(A2) for all characters, or LEN(SUBSTITUTE(A2," ","")) to leave out the spaces.

Does it work in Google Sheets?

The single-cell formulas are identical. For the whole-range version, SUMPRODUCT handles the array in both programs.

Don't want to write it by hand?

Describe what you need in plain English and get a ready-to-use formula in seconds.

Try the formula generator