FormulaCraft

How to count cells that contain a substring in Excel and Google Sheets

Excel & Google Sheets
=COUNTIF(A2:A6,"*apple*")

Verified example

Computed by a real spreadsheet engine on the sample data below.

Product
Green Apple
Pineapple Juice
Banana
Apple Cider
Mango Smoothie

=COUNTIF(A2:A6,"*apple*")3

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1Select the output cell.
  2. 2Type =COUNTIF( then select the range, e.g. A2:A6.
  3. 3For the criterion, type "*" & D1 & "*" if the search term is in D1, or hard-code it as "*apple*".
  4. 4Close the parenthesis and press Enter.
  5. 5The asterisk wildcard matches zero or more characters, so *apple* matches 'pineapple', 'apple pie', and 'Apple' (case-insensitive).

Tips

Need it for your exact data?

Describe your columns in plain English and get the precise formula for your sheet, with the right Excel or Sheets syntax.

Frequently asked

How do I count cells that contain a number as a substring?

Use the wildcard approach: =COUNTIF(A2:A6,"*5*") counts cells containing the digit 5 anywhere. COUNTIF converts numbers to text for wildcard matching.

What if I want case-sensitive substring matching?

Use =SUMPRODUCT((ISNUMBER(FIND("apple",A2:A6)))*1). FIND is case-sensitive while SEARCH is not.

Formulas used

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: