ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Conditional math
  3. COUNTIF Contains Text: Count Partial Matches

COUNTIF Contains Text: Count Partial Matches

By ExcelReady Team·Updated November 1, 2026·6 min read

The short answer

To count cells that contain a word anywhere in the text, put asterisks around it: =COUNTIF(A2:A8,"blue"). The * wildcard stands for any number of characters, so the formula counts "Blue Jeans", "Navy Blue Jacket" and "Light blue Cap". For a word in a cell, use ""&E1&"". COUNTIF ignores capitals.

Key takeaways

  • "word" means contains, "word*" means starts with, and "*word" means ends with.
  • To use a cell, join the asterisks to it: ""&E1&"".
  • "<>word" counts the cells that do not contain the word.
  • COUNTIF is not case-sensitive; use SUMPRODUCT with FIND for a case-sensitive count.
  • Wildcards only match text, so they won't find digits inside real numbers.
On this page+
  1. Why an exact COUNTIF misses partial matches
  2. How to count cells that contain text
  3. Starts with and ends with
  4. How to use a word from a cell
  5. How to count cells that contain two words
  6. Case-sensitive contains with FIND
  7. Why COUNTIF contains text returns 0
  8. How to list the matching cells, not just count them
  9. Practise it

COUNTIF contains text counts the cells where a word appears anywhere, not only cells that match it exactly. The trick is the asterisk wildcard: =COUNTIF(A2:A8,"*blue*") counts every cell with "blue" somewhere inside. This guide shows contains, starts with and ends with, how to use a word from a cell, how to count cells that don't contain a word, and what to do when you need capitals to matter.

Why an exact COUNTIF misses partial matches#

A plain text criteria in COUNTIF must match the whole cell. Look at this product list in A1:A8:

A
1Product
2Blue T-shirt
3Red Hoodie
4Navy Blue Jacket
5Blue Jeans
6Green T-shirt
7Light blue Cap
8Black Hoodie

=COUNTIF(A2:A8,"blue") returns 0. No cell is exactly "blue", so nothing matches, even though four products clearly contain the word. To match part of a cell, you need wildcards. The basics of COUNTIF are in how to use COUNTIF.

How to count cells that contain text#

Put an asterisk (*) on each side of the word. In a criteria, * stands for "any number of characters, including none":

Excel formula
=COUNTIF(A2:A8,"*blue*")

The result is 4: Blue T-shirt, Navy Blue Jacket, Blue Jeans and Light blue Cap. Read the pattern as "anything, then blue, then anything". COUNTIF ignores capitals, so "Light blue Cap" counts even though it uses a lower-case b.

The word can be part of a longer word, too. "*shirt*" matches "T-shirt" and would also match "Sweatshirt". If you only want whole words, add spaces inside the pattern, such as "* shirt*", and check the results by eye.

Starts with and ends with#

Move the asterisk to choose where the word must appear:

QuestionCriteriaFormulaResult
Contains blue"*blue*"=COUNTIF(A2:A8,"*blue*")4
Starts with blue"blue*"=COUNTIF(A2:A8,"blue*")2
Ends with hoodie"*hoodie"=COUNTIF(A2:A8,"*hoodie")2
Doesn't contain blue"<>*blue*"=COUNTIF(A2:A8,"<>*blue*")3
Any text at all"*"=COUNTIF(A2:A8,"*")7

"Starts with blue" finds Blue T-shirt and Blue Jeans. "Ends with hoodie" finds Red Hoodie and Black Hoodie. The <> in front means "not", so "<>*blue*" counts the three products without blue: Red Hoodie, Green T-shirt and Black Hoodie. Be aware that it also counts blank cells, because an empty cell doesn't contain blue either.

There is a second wildcard, ?, which stands for exactly one character. "T-shirt?" would match "T-shirts" but not "T-shirt". The guide to wildcards in COUNTIF and SUMIF covers both in depth.

How to use a word from a cell#

To change the word without editing the formula, type it in a cell and join the asterisks to it with &. With hoodie in E1:

Excel formula
=COUNTIF(A2:A8,"*"&E1&"*")

The result is 2. Excel builds the text "*hoodie*" and then counts. Change E1 to blue and the result becomes 4. The asterisks must be inside quotes, and the cell reference outside them. Writing "*E1*" searches for the letters E1.

This setup is useful for a small summary table: list several keywords in E1:E3, put the formula next to the first one with the range locked ($A$2:$A$8), and fill it down.

How to count cells that contain two words#

For AND logic, where a cell must contain both words, use COUNTIFS with the same range twice:

Excel formula
=COUNTIFS(A2:A8,"*blue*",A2:A8,"*shirt*")

The result is 1: only Blue T-shirt contains both. For OR logic, where either word counts, adding two COUNTIFs works only when no cell contains both. =COUNTIF(A2:A8,"*blue*")+COUNTIF(A2:A8,"*hoodie*") gives 4 + 2 = 6 here, which is right because no product is a blue hoodie. If one were, it would be counted twice.

Case-sensitive contains with FIND#

COUNTIF never cares about capitals. When case matters, for example to count product codes that contain "XL" but not "xl", use SUMPRODUCT with FIND:

Excel formula
=SUMPRODUCT(--ISNUMBER(FIND("Blue",A2:A8)))

FIND returns the position of "Blue" in each cell, or an error if it isn't there, and it respects capitals. ISNUMBER turns each result into TRUE or FALSE, and -- turns those into 1s and 0s for SUMPRODUCT to add. The result is 3: Light blue Cap is left out because its "blue" is lower case.

Why COUNTIF contains text returns 0#

If the count is lower than you expect, check these:

  1. No asterisks. "blue" only matches cells that are exactly "blue". Use "*blue*".
  2. The cell reference is inside the quotes. Write "*"&E1&"*", not "*E1*".
  3. The values are numbers. Wildcards only match text. "*5*" won't count the number 150, because 150 is a number, not text.
  4. Spelling differences. "Grey" and "Gray" are different words to Excel. Hidden extra spaces don't break a contains match, but they do break exact matches.
  5. You need a real asterisk. To count cells that contain an actual * or ?, put a tilde in front: "*~**".

For more causes, see COUNTIF not working. To count any text cell at all, read how to count cells with text, and to add up numbers for the matching rows instead of counting them, use SUMIF contains text.

How to list the matching cells, not just count them#

A count tells you how many cells match, but sometimes you need to see which ones. In Excel 2021 or Microsoft 365, FILTER with SEARCH lists them:

Excel formula
=FILTER(A2:A8,ISNUMBER(SEARCH("blue",A2:A8)))

The formula spills the four blue products into the cells below it. SEARCH ignores capitals, like COUNTIF, and it doesn't need asterisks, because it already looks for the text anywhere in the cell. In older versions, add a helper column with =ISNUMBER(SEARCH("blue",A2)), fill it down, and filter it for TRUE (Data > Filter). Comparing the list with your COUNTIF result is a quick way to check that the pattern matches what you meant.

Practise it#

Wildcards look strange until you have typed them a few times. Practise wildcards in criteria in a live spreadsheet, then practise COUNTIF with every kind of criteria. Each lesson checks your formula instantly. The COUNTIF function guide has the syntax on one page.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

How many products have blue anywhere in the name? In D2, use COUNTIF with wildcards on A2:A8.

fx
ABCDE
1
Product
Stock
2
Blue T-shirt
24
Contains blue
3
Red Hoodie
12
4
Navy Blue Jacket
8
5
Blue Jeans
30
6
Green T-shirt
15
7
Light blue Cap
40
8
Black Hoodie
10
9
10
11

Tip: Put an asterisk on both sides of the word, inside the quotes: "*blue*".

Practise this in a lesson

LessonWildcards and cell-based criteriaMatch partial text with * and ?, and build criteria from cells like ">"&H5 so your formulas adapt.LessonCOUNTIFCount the cells that match a condition, from exact words to number checks like ">=8".Function guideCOUNTIFCount cells that match one condition with COUNTIF: text, numbers, wildcards and cell references. Real examples and a live exercise.

Frequently asked questions

How do I count cells that contain specific text in Excel?

+

Use COUNTIF with an asterisk on each side of the text: =COUNTIF(A2:A8,"blue"). The asterisks mean any characters can come before or after the word.

How do I use COUNTIF contains with a cell reference?

+

Join the asterisks to the cell with ampersands: =COUNTIF(A2:A8,""&E1&""). Type the word you want in E1 and the count updates.

How do I count cells that do not contain a word?

+

Put <> in front of the wildcard pattern: =COUNTIF(A2:A8,"<>blue"). Blank cells in the range are counted too, because they don't contain the word.

Is COUNTIF contains case-sensitive?

+

No. "blue" matches Blue, blue and BLUE. For a case-sensitive count, use =SUMPRODUCT(--ISNUMBER(FIND("Blue",A2:A8))), because FIND respects capitals.

How do I count cells that contain two words?

+

Use COUNTIFS with the same range twice: =COUNTIFS(A2:A8,"blue",A2:A8,"shirt"). A cell is counted only if it contains both words.

Sources

  • COUNTIF function - Microsoft Support
  • COUNTIFS function - Microsoft Support
  • FIND, FINDB functions - Microsoft Support

Written and checked by the ExcelReady Team. First published November 1, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. Why an exact COUNTIF misses partial matches
  2. How to count cells that contain text
  3. Starts with and ends with
  4. How to use a word from a cell
  5. How to count cells that contain two words
  6. Case-sensitive contains with FIND
  7. Why COUNTIF contains text returns 0
  8. How to list the matching cells, not just count them
  9. Practise it

Keep reading

Errors & fixes· 5 min read

COUNTIF Not Working? Common Causes and Fixes

COUNTIF usually returns 0 or a low count because the criteria doesn't match the cells exactly. The most common causes are extra spaces in the data, numbers stored as text, missing quotes around text or operators, and a cell reference typed inside quotes. Clean the data with TRIM, write criteria like ">="&E1, and use wildcards for partial matches.

Conditional math· 6 min read

SUMIF Contains Text: Sum by Partial Match

To add up rows whose text contains a word, wrap the word in asterisks: =SUMIF(A2:A8,"*hotel*",B2:B8). The * wildcard means any characters, so the formula adds "Hotel London" and "Hotel Paris". Use "*"&D1&"*" for a word in a cell, "<>*hotel*" to exclude it, and SUMIFS when the text must contain two words.

Conditional math· 6 min read

How to Use COUNTIF in Excel (With Criteria Examples)

COUNTIF counts the cells in a range that meet one condition. Write =COUNTIF(range, criteria), for example =COUNTIF(D2:D9,"Open") to count open tickets. Put text and comparisons in double quotes, like ">=8" or "<>Low". Numbers and cell references go in without quotes. For two or more conditions, use COUNTIFS.

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free