Mastering Excel's COUNTIF with Text Criteria: The CONTAINS Function
In the vast world of Excel, the COUNTIF function is a powerhouse for data analysis. While it's typically used with numerical criteria, Excel also offers a way to count cells based on text criteria using the CONTAINS function. Let's dive into this powerful combination and explore how to use it to its full potential.
Understanding the Basics: COUNTIF and CONTAINS
The COUNTIF function counts the number of cells that meet a specific criteria. The syntax is simple: COUNTIF(range, criteria). The CONTAINS function, on the other hand, is an Excel 365 feature that checks if one text string contains another. It uses the following syntax: CONTAINS(text, search).
Using COUNTIF with CONTAINS: The Power Duo
To use COUNTIF with CONTAINS, you'll need to nest the functions. The basic syntax looks like this: COUNTIF(range, CONTAINS(search_text, cell_value)). Here's a breakdown:

- range: The range of cells you want to evaluate.
- search_text: The text you're looking for within the cells in the range.
- cell_value: The value in each cell within the range that Excel checks.
Practical Example: Counting Text Occurrences
Let's say you have a list of names in cells A1:A10, and you want to count how many names contain the text "John". You would use the following formula:
=COUNTIF(A1:A10, CONTAINS("John", A1:A10))
Wildcards and Special Characters
You can also use wildcards and special characters to refine your search. For instance, to count names that start with "J", you would use:

=COUNTIF(A1:A10, CONTAINS("J*", A1:A10))
In this case, the asterisk (*) acts as a wildcard, matching any text after "J".
Counting Multiple Occurrences in a Single Cell
What if you want to count multiple occurrences of a text within a single cell? For example, you have a list of emails in cells A1:A10, and you want to count how many times the text "@gmail.com" appears. You can use the following formula:

=COUNTIF(A1:A10, "*@gmail.com*")
In this case, the asterisks (*) before and after "@gmail.com" ensure that Excel counts occurrences even if the text appears at the beginning or end of a cell.
Real-World Applications and Best Practices
The COUNTIF with CONTAINS combination has numerous real-world applications, from counting specific words in a text to analyzing data based on certain criteria. Here are some best practices to keep in mind:
- Use named ranges to make your formulas easier to read and update.
- Consider using structured references (e.g.,
Table1[Column1]) if you're working with tables. - Always double-check your formulas to ensure they're counting what you expect.
Incorporating COUNTIF with CONTAINS into your Excel skillset can greatly enhance your data analysis capabilities. With a bit of practice, you'll be counting text occurrences like a pro in no time. Happy counting!




















