Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Counting Asterisks.

Counting Asterisks

Written by Allen Wyatt (last updated March 28, 2026)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365


2

David needs to count the number of asterisks that appear in a range of cells. He notes that COUNTIF appears to assume that * is a wild card character, so it doesn't return the proper count.

There are a number of ways to get results, based upon what it is you actually want to get. Let's assume that you have the following values in cells A3:A8:

  • 1234
  • abcd
  • ab*cd
  • ab*c*d
  • *
  • ***

In these six cells there are a total of seven asterisks. To determine the number of asterisks appearing within the range, you'll need to rely upon an array formula, such as this one:

=SUM(LEN(A3:A8)-LEN(SUBSTITUTE(A3:A8,"*","")))

Remember to enter the formula with Ctrl+Shift+Enter if you are using an older version of Excel (Excel 2019 or older).

Of course, you might want to count the number of cells in the range that contain a single asterisk instead of the number of actual asterisks. In this case you can actually use the COUNTIF function, provided you know how to put the formula together. First, try this formula:

=COUNTIF(A3:A8,"*")

With the data shown at the beginning of this tip, this formula returns the value 5. This, of course, is wrong. The reason it returns this result is because COUNTIF uses * as a wildcard that means "any text in the cell." Since there are five cells in the range that contain text (non-numeric values), that is the answer returned by the formula.

You might think that if you searched for the ANSI character of the asterisk, instead of the asterisk itself, you could get the correct result. This formula shows this approach:

=COUNTIF(A3:A8,CHAR(42))

This formula also returns the incorrect answer (5). It appears that Excel sees no difference, in application, between searching for * and searching for CHAR(42). Both are still treated as a wildcard.

The solution to this is to remember that you can force Excel to treat the asterisk as an actual character by preceding it with a tilde, character, in this manner:

=COUNTIF(A3:A8,"~*")

This returns a result of 1, which may be surprising. Excel is very literal, however, and your formula asked for a count of all the cells which contain nothing but a single asterisk. The correct answer is that only one cell (A7) contains what you asked for. If you want to count all the cells that contain an asterisk anywhere within the cell, then you need to surround the search parameter with wildcard characters, in this manner:

=COUNTIF(A3:A8,"*~**")

This returns "any text" followed by a literal asterisk followed by "any text." The result is 4, which is the number of cells that contain at least one asterisk.

The concept of using tildes to counteract wildcards is covered in this Knowledge Base article:

https://support.office.com/en-us/article/find-or-replace-text-and-numbers-on-a-worksheet-0e304ca5-ecef-4808-b90f-fdb42f892e90

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9483) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Counting Asterisks.

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

Calculating Future Workdays

Need to calculate the date that is a certain number of workdays in the future? You can do so using a couple of different ...

Discover More

Keeping Fields and Text Together

You can use fields for a wide variety of purposes in your documents. If you want to make sure that a field and the text ...

Discover More

Adding Tabs at the Beginning of a Line

Press a tab at the beginning of a paragraph, and Word normally assumes you want to indent the paragraph. If you don't ...

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!

More ExcelTips (ribbon)

Generating Numeric Testing Data

Excel can be used to generate random testing data that you can use in any way you deem necessary. This tip provides ...

Discover More

Cell and Name References in COUNTIF

The second parameter of the COUNTIF function is used to specify the criteria to be used when determining what should be ...

Discover More

Hiding Rows Based on Two Values

It's easy to use filtering to hide rows based on the value in a cell, but how do you hide rows based on the values in two ...

Discover More
Subscribe

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

View most recent newsletter.

Comments

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 more than 7?

2026-03-31 13:44:16

J. Woolley

The Tip's first formula is a good solution; I don't have a better one. But here's some alternative formulas using regular expressions:
    =COUNTA(REGEXEXTRACT(CONCAT(A3:A8), "\*", 1))
    =SUM(LEN(REGEXEXTRACT(CONCAT(A3:A8), "\*", 1)))
    =LEN(REGEXREPLACE(CONCAT(A3:A8), "[^\*]", ""))
REGEXEXTRACT and REGEXREPLACE currently require Excel 365; CONCAT requires Excel 2019. Older versions can use these equivalent CSE array formulas supported by My Excel Toolbox:
    =COUNTA(RegExMatch(JoinAsText("", TRUE, A3:A8), "\*", 1))
    =SUM(LEN(RegExMatch(JoinAsText("", TRUE, A3:A8), "\*", 1)))
    =LEN(RegExSubstitute(JoinAsText("", TRUE, A3:A8), "[^\*]", ""))
JoinAsText is similar to Excel 2019's TEXTJOIN; both work like CONCAT when their first argument is a null string.
See https://sites.google.com/view/MyExcelToolbox/


2026-03-29 11:10:21

J. Woolley

After its first formula the Tip says, "Remember to enter the formula with Ctrl+Shift+Enter if you are using an older version of Excel (Excel 2019 or older)." You can enter the formula with Ctrl+Shift+Enter (CSE) in newer versions of Excel, too, because they work with CSE arrays as well as dynamic arrays. If your version supports dynamic arrays, Ctrl+Shift+Enter is optional.


This Site

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

Newest Tips
Subscribe

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

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.