Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Counting Cells with Specific Characters.

# Counting Cells with Specific Characters

by Allen Wyatt
(last updated June 10, 2020)

Let's say that you have a worksheet that contains all the people who have ever worked in your department. Each name is prefaced by a single character that indicates the status of the person. For instance, if Fred Davis were retired, his name might show up as "RFred Davis". With quite a lot of these names in the worksheet, you may need a way to count those people with a specific status character.

The easiest way to accomplish this is to use the COUNTIF function. If, for instance, the status character is the letter R (for "retired"), and your range of names is in cells A5:A52, then you could use the following to determine which cells begin with the letter R:

```=COUNTIF(A5:A52,"R*")
```

The formula works because the comparison value is R*, which means "the letter R followed by any other characters." Excel dutifully returns the count. To search for a different status character, simply replace R with the desired status character.

Obviously, if the asterisk has a special meaning in this usage, you can't search directly for an asterisk. Actually, there are three characters you cannot search for directly: the asterisk (*), the question mark (?) and the tilde (~). If you want to search for any of these characters, you must precede the character with the tilde. Thus, if you wanted to determine a count of names that had a question mark as a status code, you could use the following:

```=COUNTIF(A5:A52,"~?*")
```

An alternative to using COUNTIF is to create an array formula that is applied to every cell in the range. The following will do the trick very nicely:

```=SUM((LEFT(A5:A52,1)="R")*1)
```

This must, of course, be entered as an array formula. This means that instead of pressing Enter at the end of the formula, you would press Shift+Ctrl+Enter. The formula checks the left-most character of a cell, returning the value TRUE if it is R or FALSE if it is not. The multiplication is done to convert the TRUE/FALSE value to a number, either 1 for TRUE or 0 for FALSE. The SUM function returns the sum, or count, of all the cells that meet the criteria.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2342) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Counting Cells with Specific Characters.

##### Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

##### MORE FROM ALLEN

Working With Multiple Workbooks

Need to do work in more than one workbook at a time? For many, this ability is a necessity. Excel allows you to easily ...

Discover More

Using Mandatory Form Fields

When using form fields to gather information from users of your documents, you may want to make sure that some of the ...

Discover More

Suppressing Endnotes

Endnotes are a beneficial necessity for some documents. If you want to print a copy of the document without endnotes, ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

Counting with Formulas

When you need to count a number of cells based upon a single criteria, the standard function to use is COUNTIF. This tip ...

Discover More

Finding the Lowest Numbers

Need to find the lowest numbers in a range of values? It's easy to do using the SMALL worksheet function, or you can use ...

Discover More

Using GEOMEAN with a Large List

When performing a statistical analysis on a large dataset, you may want to use GEOMEAN to figure out the geometric mean ...

Discover More
##### Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. Youâ€™ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is three less than 9?

2018-11-26 12:28:52

ROY

Liz, you can use SUBSTITUTE() and LEN() to achieve that:

Say you are looking for "B", "L", and "c" in cell A1:

=( (LEN(A1) - LEN( SUBSTITUTE(A1, "B", "")) + (LEN(A1) - LEN( SUBSTITUTE(A1, "L", "")) + (LEN(A1) - LEN( SUBSTITUTE(A1, "c", "")) )

It will NOT yield an error if the count is zero for a letter so no need for error handling.

(SUBSTITUTE() is case sensitive so it will distinguish between "B" and "b" and so on. As the saying goes though: "However it is case sensitive so...": you must watch case, or allow for it, when entering the letters, which is easier if you do the following.)

It is also happy to accept cell references for the search text (the letters) so you can have an easily changed list of letters to check for. NOT a RANGE of references in a one-third of the above formula, but individual cell references. If you do that, you can watch for some entry errors like they should all be upper case or lower case by wrapping the reference in the applicable function:

SUBSTITUTE( A1, UPPER( N7 ), "")

Also worth mentioning while using SUBSTITUTE(), there are quite a few uses that compare a cell/string length before and after using SUBSTITUTE().

2018-03-06 12:55:59

Liz

In the same column I need to count multiple different letters to make one total of the different letters. Any assistance would be helpful!

##### This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.