Count Cells Containing a Word or Phrase in Excel with COUNTIF
Question details
Count cells that contain a word or phrase within longer text, or count every occurrence of that text.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet contains text such as product names or descriptions, and the user wants to find cells containing a particular term.
- Observed behavior
- An exact-match COUNTIF criterion counts cells whose entire contents match the term, rather than cells that contain it within longer text.
Identify the range to search and the exact text or phrase you want to count. Decide whether you need the number of matching cells or the total number of occurrences, since these can produce different results.
Use COUNTIF wildcards to count cells containing text
Use this method when each matching cell should count once, even if the text appears multiple times in that cell.
In Excel, click an empty cell where you want the count to appear.
Type =COUNTIF(A1:A100,"*apple*") and press Enter. Replace A1:A100 with your range and apple with your word or phrase.
Compare the result with the cells in your selected range. The asterisks allow text before or after the search term.

Count every occurrence with LEN and SUBSTITUTE
Use this method when repeated instances in the same cell should each be counted.
Count cells containing text in WPS Spreadsheets
Use COUNTIF and asterisk wildcards in WPS Spreadsheets to count cells containing a word or phrase within longer text.
- 1. Open your spreadsheet: Launch WPS Spreadsheets and open the workbook containing the text you want to count.
- 2. Select a result cell: Click an empty cell where you want to display the count.
- 3. Enter the formula: Type =COUNTIF(A1:A100,"*apple*") in the cell or formula bar, replacing the range and search term as needed.
- 4. Display the count: Press Enter to count cells containing the search term.

Frequently Asked Questions
Does COUNTIF count a cell twice if the word appears twice?
No. =COUNTIF(A1:A100,"*apple*") counts each matching cell once. Use the LEN and SUBSTITUTE formula in the second solution to count repeated occurrences.
Is the COUNTIF text search case-sensitive?
No. COUNTIF treats uppercase and lowercase text as equivalent. The SUBSTITUTE occurrence-counting formula is case-sensitive.
Can I search for a phrase instead of one word?
Yes. Put the phrase between the wildcards, for example, =COUNTIF(A1:A100,"*apple pie*").
How do I count a literal asterisk or question mark?
In a COUNTIF criterion, place a tilde before the character to treat it as literal. For example, =COUNTIF(A1:A100,"*~**") counts cells containing an asterisk.
Why does an older version of Excel need Ctrl+Shift+Enter?
The LEN and SUBSTITUTE formula processes a range as an array. In older Excel versions, select the formula cell and confirm the formula with Ctrl+Shift+Enter.




