Go Back

Count Cells That Contain Five Characters

While working with Excel, we are able to count values in a data set based on a given criteria by using the COUNTIF function.  COUNTIF returns the number of values in a specified range based on a given condition.  This step by step tutorial will assist all levels of Excel users in counting values that contain five characters.  

Figure 1. Final result: Count cells that contain five characters

Final formula: =COUNTIF(B3:B7,"?????")

Syntax of COUNTIF Function



  • range – the data range that will be evaluated using the criteria
  • criteria – the criteria or condition that determines which cells will be counted

Setting up our Data

Our data consists of two columns : State (column B) and No. of Characters (column C).  In cell E3, we want to determine how many states in the list have five characters.

Figure 2. Sample data for the COUNTIF function

Count cells that contain five characters

To determine the number of cells that contain five characters, we follow these steps:

Step 1.  Select cell E3

Step 2.  Enter the formula: =COUNTIF(B3:B7,"?????")

Step 3.  Press ENTER

The range for the database is B3:E7.  The criteria is “?????”.  The question mark “?” is a wildcard in Excel which means one single character.  Using five question mark symbols as criteria means that we want to find values with five characters.  

The result in cell E3 is 2, which means that there are two values with five characters: Idaho and Texas.  

Figure 3. Entering the formula using COUNTIF and question mark “?”

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 need some help with conditional formatting of cells that contain certain special characters
Solved by B. W. in 13 mins
I want to add a row of cells in excel where some cells contain numbers and sum contain characters which will change after each entry. I only want to add the cells that contain numbers after each calculation? eg Total Anthony 6 | ###| 5 | ~~~ | 2 | 11 |
Solved by I. L. in 15 mins
I want Excel to count a range of cells that contain specific data
Solved by B. L. in 13 mins

Leave a Comment