Google Sheets COUNTIF contains text: wildcards and IF
To count cells that contain text, put an asterisk on each side of the keyword, as in "*late*". Then an if cell contains Yes or No for each row.
On this page
=COUNTIF(B2:B11, "*"&E2&"*")Before as you see it
| B | C | D | E | F | |
|---|---|---|---|---|---|
| 1 | Note | Has keyword? | Keyword | Notes with keyword | |
| 2 | Delivery came late again | No | late | 1 | |
| 3 | Great service, friendly driver | No | |||
| 4 | Order was late and the box was damaged | No | |||
| 5 | late | No | |||
| 6 | Loved the chocolate muffins | No | |||
| 7 | Late by two days | No | |||
| 8 | Driver was polite | No | |||
| 9 | Can you deliver on Sundays? | No | |||
| 10 | Wrong item, please call me | No | |||
| 11 | Running late is fine, food was hot | No |
What changed
F2criterion wrapped in"*"C2:C11use COUNTIF inside IF
After wildcards added
| B | C | D | E | F | |
|---|---|---|---|---|---|
| 1 | Note | Has keyword? | Keyword | Notes with keyword | |
| 2 | Delivery came late again | Yes | late | 6 | |
| 3 | Great service, friendly driver | No | |||
| 4 | Order was late and the box was damaged | Yes | |||
| 5 | late | Yes | |||
| 6 | Loved the chocolate muffins | Yes | |||
| 7 | Late by two days | Yes | |||
| 8 | Driver was polite | No | |||
| 9 | Can you deliver on Sundays? | No | |||
| 10 | Wrong item, please call me | No | |||
| 11 | Running late is fine, food was hot | Yes |
To count cells that contain a word in Google Sheets, put an asterisk on each side of it in the COUNTIF criterion, as in =COUNTIF(B2:B11, "*late*"). Without the asterisks, COUNTIF only counts cells whose entire text is the keyword. With the word in its own cell, E2, the criterion becomes "*"&E2&"*". In this sheet, that change in F2 takes the count from 1 to 6.
This sheet gives three answers to one question: 1, 6 or 5. The question is how many of the ten customer notes in B2:B11 mention late, and the answer depends on which formula asks it. All three formulas read the same notes and the same keyword.
| Method and formula | Returned, and the notes counted |
|---|---|
Plain keyword=COUNTIF(B2:B11, E2) | 1 (row 5 only) |
Wildcards=COUNTIF(B2:B11, "*"&E2&"*") | 6 (rows 2, 4, 5, 6, 7, 11) |
Whole word=SUMPRODUCT(--REGEXMATCH(B2:B11, "(?i)\blate\b")) | 5 (rows 2, 4, 5, 7, 11) |
Read by eye, five of the notes use the word, from Jessica's delivery in row 2 to Josh's note in row 11. The plain COUNTIF on the Broken tab finds one of them. The wildcard version on the Fixed tab finds six, one more than the eye count, and the REGEXMATCH version on the More cases tab lands on five. A Yes or No for each row takes the same wildcards, with COUNTIF pointed at a single cell inside IF: =IF(COUNTIF(B2, "*"&$E$2&"*"), "Yes", "No").
COUNTIF with a plain keyword matches the whole cell
The 1 in F2 on the Broken tab comes from row 5. Given a plain word, COUNTIF compares it with the entire cell, so a note counts only when late is all it says. Matthew's note is that one word. Jessica's "Delivery came late again" has the word in the middle and fails the comparison, along with every other note that uses late in a sentence.
Exact matching suits a column where each cell holds one value, like a status code, and counting two such codes at once is covered in COUNTIF with OR. Feedback notes are full sentences, so the plain criterion skips four of the five notes that use the word.
Counting cells that contain text: an asterisk on each side of the keyword
The Fixed tab changes F2 to =COUNTIF(B2:B11, "*"&E2&"*"). The ampersands join an asterisk to each side of whatever sits in E2, so COUNTIF receives *late*. Google's COUNTIF help page lists two wildcards a criterion can hold: ? for any single character and * for zero or more characters in a row. With one on each side, any text may come before late and any text may follow it, and "any" includes nothing at all. That is why Matthew's one-word note still counts.
F2 on the Fixed tab returned 6. Because the formula adds the asterisks, E2 stays a plain word, and typing a different keyword there changes what gets counted without touching the formula. In a sheet of your own, the range B2:B11 and the keyword cell are the two parts to change. To skip the keyword cell, put the whole pattern inside one pair of quotes, =COUNTIF(B2:B11, "*late*"). That version sits in F2 of the More cases tab and also returned 6. Either way the asterisks go inside the criterion. The formula itself still starts with an equals sign.

| Input | 10 notes in B2:B11, keyword late in E2 |
|---|---|
| Formula | =COUNTIF(B2:B11, "*"&E2&"*") |
| Expected | 6 |
| Sheets returned | 6 Matches expected |
| Checked | 2026-11-11, free personal account |
An "if cell contains" Yes or No per row, with COUNTIF inside IF
Column C asks the same question one row at a time and answers Yes or No. On the Broken tab every row runs =IF(B2="*"&$E$2&"*", "Yes", "No"), with the asterisks already in place, and all ten rows say No. That includes row 5, where the note is the keyword itself.
An equals sign does no pattern matching. In B5="*"&$E$2&"*" it checks whether Matthew's note is literally an asterisk, the letters l, a, t, e, and another asterisk. The note is just the four letters, so C5 returns No.

The Fixed tab hands the matching to COUNTIF and gives it a range of one cell. C2 holds =IF(COUNTIF(B2, "*"&$E$2&"*"), "Yes", "No"). Counting a single cell can only give 1 or 0, and IF treats 1 as true and 0 as false. Copied down to C11, the column says Yes on six rows and No on four, and the six are the notes F2 counts.
Keep the dollar signs in $E$2. They pin every copy of the formula to the keyword cell. Without them, the copy in C3 would read E3, and E3 is empty.
Whole-word matches with REGEXMATCH, so chocolate stops counting as late
Six is one more than the five notes that use the word. The extra one is row 6, where Sarah loved the chocolate muffins. Chocolate ends in l-a-t-e, and *late* has no idea where a word starts.
For a whole-word count, F7 on the More cases tab holds =SUMPRODUCT(--REGEXMATCH(B2:B11, "(?i)\blate\b")), and it returned 5. REGEXMATCH tests each note against a regular expression and gives back TRUE or FALSE. The double minus turns those into 1s and 0s for SUMPRODUCT to add up. In the pattern, \b marks a word boundary, so the letters right before late in chocolate block the match. The (?i) at the front turns off case matching, which keeps David's capitalized Late in the count. The REGEXMATCH help page says Sheets follows RE2 syntax for these patterns.
Column C on the More cases tab is the per-row version, =IF(REGEXMATCH(B2, "(?i)\blate\b"), "Yes", "No"). Against column C of the Fixed tab, one row differs. Sarah's chocolate note says No there.

Capital letters, "?" and "~" in a COUNTIF criterion
The rest of the More cases tab tries other patterns on the same ten notes.
| Criterion in COUNTIF(B2:B11, ...) | Matches | Returned |
|---|---|---|
"*late*" | late anywhere in the note | 6 |
"*Late*" | the same, typed with a capital L | 6 |
"late*" | notes that begin with late | 2 |
"*?*" | any note with at least one character | 10 |
"*~?*" | notes containing a question mark | 1 |
"<>*late*" | notes without late anywhere | 4 |
The capital L changed nothing, and the COUNTIF help page says outright that COUNTIF is not case sensitive. When case does matter, drop (?i) from the regular expression. =SUMPRODUCT(--REGEXMATCH(B2:B11, "Late")) returned 1, for David's note.
Inside a criterion, ? stands for any one character, so "*?*" matched all 10 notes. A tilde in front, ~?, makes it a literal question mark, and the count fell to 1, Chris asking about Sundays. Per the same help page, a tilde does the same job for a literal asterisk, and two tildes match one tilde.
Trying the wildcard COUNTIF and the IF version on the Try it yourself tab
Try it yourself is a copy of the Broken tab, with 1 in F2 and No all the way down column C. Replace F2 with =COUNTIF(B2:B11, "*"&E2&"*"). Then replace C2 with =IF(COUNTIF(B2, "*"&$E$2&"*"), "Yes", "No") and drag the small square at the corner of C2 down to C11. F2 should read 6, and column C should match the Fixed tab row for row.
If chocolate should not count in your own notes, use the REGEXMATCH formulas from the More cases tab in those two cells instead. Their pattern has late typed into it rather than a reference to E2, so a new keyword means editing the pattern.
A ? or * typed into E2 passes through the "*"&E2&"*" wrapper and acts as a wildcard there too. To count a literal one, type it into E2 with a tilde in front.
Take-home copy. Four tabs: Broken (as you see it), Fixed, Try it yourself, More cases. It opens as a copy in your own Drive.