Mastering Excel's COUNTIF with Text Containment
In the vast world of data analysis, Microsoft Excel stands as a powerhouse, offering a myriad of functions to simplify complex tasks. One such function is COUNTIF, which is incredibly versatile when it comes to counting cells based on specific criteria. Today, we're going to delve into a lesser-known aspect of COUNTIF: counting cells that contain specific text.
Understanding the Challenge
By default, Excel's COUNTIF function is designed to count cells based on numerical values or exact text matches. However, real-world data often contains text in varying formats, making it challenging to count cells with specific text using standard COUNTIF. This is where our focus lies - making COUNTIF work for text containment.
Introducing Wildcards in COUNTIF
Excel introduces wildcards - asterisk (*) and question mark (?) - to help us overcome this challenge. These wildcards act as placeholders in our criteria, allowing us to match any text before or after the specified text. Let's explore how to use them.

Using COUNTIF with Wildcards
Wildcards can be incredibly powerful when used correctly. Here's how you can use them in your COUNTIF function:
- Asterisk (*): Represents any number of characters. For example, "*apple*" will match "bananaapple", "applepie", and "apple".
- Question Mark (?): Represents exactly one character. For example, "appl?e" will match "apple" but not "apples" or "appl".
Practical Examples
Let's apply these wildcards to some practical examples. Suppose we have the following data in cells A1:A10:
| Fruits |
|---|
| bananaapple |
| applepie |
| apple |
| apples |
| app |
| appl |
| appleseed |
| orange |
| cherry |
| cherries |
Counting cells containing "apple"
To count cells containing "apple", use the following formula in any empty cell: =COUNTIF(A1:A10, "*apple*"). This will return 6, as there are six cells containing "apple".

Counting cells ending with "e"
To count cells ending with "e", use =COUNTIF(A1:A10, "*e"). This will return 5, as there are five cells ending with "e".
Advanced Text Containment with COUNTIF
While wildcards are powerful, they can sometimes lead to unexpected results. For more precise text containment, you might need to use other functions like SEARCH or ISNUMBER in combination with COUNTIF. We'll explore these advanced techniques in a future article.
In the meantime, mastering COUNTIF with wildcards will significantly enhance your data analysis capabilities in Excel. So, go ahead, give it a try, and watch your productivity soar!























