Excel Count Times a Word Appears
In this article
To count how many times a word appears in an Excel range, use the COUNTIF function: =COUNTIF(range,"word"). For a case-insensitive count, this works directly; for case-sensitive counting, use SUMPRODUCT(--EXACT(range,"word")). This article explains both methods, how to handle partial matches, and common pitfalls.
in range | Range | - | A1:A10 | 0 in word | Word | - | apple | 0 out count | Count | - | COUNTIF(range, word) | 0
Formula
The basic formula is:
COUNTIF(range, criteria)
Where:
- range – the cells you want to search (e.g., A1:A10)
- criteria – the word or text you’re counting, in quotes (e.g., "apple")
For a case-sensitive count, use:
SUMPRODUCT(--EXACT(range, "word"))
Here, EXACT compares each cell exactly (case-sensitive) and returns TRUE/FALSE; the double negative (--) converts those to 1/0, and SUMPRODUCT sums them.
Worked Example
Suppose you have the following list in cells A1:A5:
- A1: apple
- A2: Apple
- A3: banana
- A4: apple pie
- A5: apple
To count how many cells contain the word "apple" (case-insensitive, exact match), enter:
=COUNTIF(A1:A5,"apple")
This returns 3 because A1, A2, and A5 match exactly (ignoring case).
If you want a case-sensitive count, use:
=SUMPRODUCT(--EXACT(A1:A5,"apple"))
This returns 2 because only A1 and A5 match exactly (A2 has capital A).
How to Count Partial Matches
If you want to count cells that contain the word as part of a longer text (like "apple pie"), use wildcards:
=COUNTIF(range,"*apple*")
This counts any cell that contains "apple" anywhere. In the example above, it would return 4 (A1, A2, A4, A5).
Be careful: wildcards work with text, but not with numbers. For numbers, use the COUNTIF with a numeric criterion, e.g., =COUNTIF(range,5).
Case-Sensitive Counting
As shown, EXACT is the key for case-sensitive counts. The formula =SUMPRODUCT(--EXACT(range,"word")) is an array formula that works without Ctrl+Shift+Enter in modern Excel. It compares each cell exactly, so "Apple" and "apple" are different.
Common Mistakes and Pitfalls
- Forgetting quotes: In COUNTIF, text criteria must be in double quotes.
=COUNTIF(A1:A10,apple)will cause an error. - Using wildcards unintentionally: If your word contains an asterisk (*) or question mark (?), Excel treats it as a wildcard. To count a literal asterisk, use
~*in the criteria. - Counting cells with extra spaces: If a cell has "apple " (trailing space), COUNTIF won’t match. Use
=COUNTIF(range,"*apple*")or trim spaces first. - Counting whole words vs. substrings: COUNTIF counts cells, not individual words. If a cell contains "apple apple", it counts as one, not two.
Alternatives and Related Functions
For more complex counting, consider:
- COUNTIFS – for multiple criteria, e.g., count cells that contain "apple" in column A and "red" in column B.
- SUMPRODUCT – for counting with logic, e.g., count cells where the word appears at the start:
=SUMPRODUCT(--(LEFT(A1:A10,5)="apple")). - LEN and SUBSTITUTE – to count how many times a word appears within a single cell:
=(LEN(A1)-LEN(SUBSTITUTE(A1,"apple","")))/LEN("apple"). - FILTER – in Excel 365, you can use
=ROWS(FILTER(range,ISNUMBER(SEARCH("apple",range))))to count cells containing the word.
When to Use Which Method
- Use COUNTIF when you need a quick, case-insensitive count of exact matches.
- Use SUMPRODUCT with EXACT when case matters.
- Use wildcards when you need to count cells that contain the word anywhere.
- Use LEN/SUBSTITUTE when you need to count occurrences within a single cell (e.g., a sentence in one cell).
Frequently Asked Questions
How do I count a word that appears multiple times in the same cell?
Use the formula =(LEN(cell)-LEN(SUBSTITUTE(cell,"word","")))/LEN("word"). This subtracts the length of the cell after removing the word from the original length, then divides by the word’s length. For example, if A1 contains "apple apple", the formula returns 2.
Why does COUNTIF return 0 when the word is there?
Most likely because of extra spaces, hidden characters, or case sensitivity. Try using =COUNTIF(range,"*"&cell&"*") if the word is in another cell, or check for trailing spaces with =LEN(cell).
Can I count words across multiple sheets?
Yes, but you need to reference each sheet separately. For example: =COUNTIF(Sheet1!A1:A10,"apple")+COUNTIF(Sheet2!A1:A10,"apple"). Or use a 3D reference if the sheets are identical: =COUNTIF(Sheet1:Sheet3!A1:A10,"apple").
How do I count words in a filtered list?
Use SUBTOTAL with function 103 (COUNTA) or 3 (COUNTA) for visible cells, but it doesn’t count specific words directly. A better approach is to use SUMPRODUCT with SUBTOTAL and OFFSET, but that’s complex. Simpler: copy the filtered data to a new location and use COUNTIF there.
Is there a way to count words without a formula?
Yes, you can use Excel’s Find and Replace. Press Ctrl+F, type the word, click "Options", and set "Within" to "Sheet" or "Workbook". The status bar shows "X cells found". This is a quick one-off method but not dynamic.
Does COUNTIF work with numbers?
Yes, but the criteria must be a number, not text. For example, =COUNTIF(A1:A10,5) counts cells equal to 5. If you want to count cells that contain the digit 5 as part of a number, you’d need to use wildcards with text, but that’s not straightforward for numbers.