Go Back

How to Count Cells that Contain Specific Text

Analyzing large chunks of data often requires to count cells containing specific text. Excel allows us to do it in a simple way. We can use the COUNTIF function to count cells that contain specific text. In this tutorial, we will learn how to count cells that contain specific text.

Figure 1. Example of Counting Cells that Contain Specific Text

Generic Formula

=COUNTIF(range,"*text*")

  • Range: This value is required. It is the range of cells where we want to count the text.
  • Text: This value is also required. It is the specific text that we want to cout. Here, the asterisk sign (“*”) represents a wildcard that matches any number of characters.

How the Formula Works

Here, COUNTIF counts the total cells containing the provided text in the range. It matches the content of the cells against the wildcard pattern. This wildcard matches any number of characters. Thus, itl counts all cells containing the text in any position. Excel returns the total number of time the text arrives in the range.

Setting Up Data

The following example uses an employee information data set. Column A, B and C has the employee names, ID and departments.

Figure 2. The Sample Data

To find the total number of employees from the HR department:

  • Go to cell F4.
  • Assign the formula =COUNTIF(C2:C6,"*HR*") to cell F4.
  • Press Enter.

Figure 3. Applying the Formula to Count Cells Containing Specific Text

This will show the number of employees in the HR department in cell F4.

Notes

We can change the previous formula to use the contents of another cell as the text criteria. To find the number of employees in the HR department using the ID’s, we need to use the formula:

=COUNTIF(B2:B6,"*"&C2&"*")

Figure 4. Using the Wildcard to Count Cells that Contain Specific Text

This shows the same result as before using the text HR from the cell C2 to look into the ID’s that matches the text HR.

Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.

Did this post not answer your question? Get a solution from connecting with the expert.

Another blog reader asked this question today on Excelchat:
Here are some problems that our users have asked and received explanations on

I want Excel to count a range of cells that contain specific data
Solved by B. L. in 13 mins
I would like to be able to search Columns D-X for cells that contain specific text and then hide all rows that do not contain that text
Solved by Z. U. in 25 mins
How to count number of rows that contain a cell that ends with specific text? all specific text have a length of 2 there are more than 10 specific texts that needs to be counted (LL, LA, FT, etc) the range is of 130 rows x 50 columns
Solved by D. Y. in 18 mins

Leave a Comment

avatar