Function Problems

Count Cells Containing a Word or Phrase in Excel with COUNTIF

Chanuka GeekiyanageChanuka Geekiyanage Dec 2, 2026 868 views

Question details

Count cells that contain a word or phrase within longer text, or count every occurrence of that text.

Count Cells Containing a Word or Phrase in Excel with COUNTIF
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.
Before you start

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.

Solution 1Recommended

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.

1
Select a result cell

In Excel, click an empty cell where you want the count to appear.

2
Enter the COUNTIF formula

Type =COUNTIF(A1:A100,"*apple*") and press Enter. Replace A1:A100 with your range and apple with your word or phrase.

3
Check the result

Compare the result with the cells in your selected range. The asterisks allow text before or after the search term.

Use COUNTIF wildcards to count cells containing text
Substring matches: COUNTIF is not case-sensitive, and this formula also matches the search term inside a longer word, such as apple in apples.
Count text in WPS Spreadsheets

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. 1. Open your spreadsheet: Launch WPS Spreadsheets and open the workbook containing the text you want to count.
  2. 2. Select a result cell: Click an empty cell where you want to display the count.
  3. 3. Enter the formula: Type =COUNTIF(A1:A100,"*apple*") in the cell or formula bar, replacing the range and search term as needed.
  4. 4. Display the count: Press Enter to count cells containing the search term.
Count matching cells with a familiar COUNTIF formulaOpen and edit Microsoft Excel XLSX and XLS filesUse a familiar spreadsheet interfaceWork with spreadsheets using the free WPS Office suite
microsoft office alternative - wps office

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.