Excel Wildcard Characters – What are these and How to Best Use it

Watch Video on Excel Wildcard Characters

There are only 3 Excel wildcard characters (asterisk, question mark, and tilde) and a lot can be done using these.

In this tutorial, I will show you four examples where these Excel wildcard characters are absolute life savers.

Excel Wildcard Characters – An Introduction

Wildcards are special characters that can take any place of any character (hence the name – wildcard). 

There are wildcard characters in Excel:

  1. * (asterisk) – It represents any number of characters. For example, Ex* could mean Excel, Excels, Example, Expert, etc.
  2. ? (question mark) – It represents one single character. For example, Tr?mp could mean Trump or Tramp.
  3. ~ (tilde) – It is used to identify a wildcard character (~, *, ?) in the text. For example, let’s say you want to find the exact phrase Excel* in a list. If you use Excel* as the search string, it would give you any word that has Excel at the beginning followed by any number of characters (such as Excel, Excels, Excellent). To specifically look for excel*, we need to use ~. So our search string would be excel~*. Here, the presence of ~ ensures that excel reads the following character as is, and not as a wildcard.

Note: I have not come across many situations where you need to use ~. Nevertheless, it is a good to know feature.

Now let’s go through four awesome examples where wildcard characters do all the heavy lifting.

Excel Wildcard Characters – Examples

Now let’s look at four practical examples where Excel wildcard characters can be mighty useful:

  1. Filtering data using a wildcard character.
  2. Partial Lookup using wildcard character and VLOOKUP.
  3. Find and Replace Partial Matches.
  4. Count Non-blank cells that contain text.

#1 Filter Data using Excel Wildcard Characters

Excel wildcard characters come in handy when you have huge data sets and you want to filter data based on a condition.

Suppose you have a dataset as shown below:

Excel Wildcard Characters - Data Companies

You can use the asterisk (*) wildcard character in data filter to get a list of companies that start with the alphabet A.

Here is how to do this:

  • Select the cells that you want to filter.
  • Go to Data –> Sort and Filter –> Filter (Keyboard Shortcut – Control + Shift + L).
  • Click on the filter icon in the header cell Wildcard Characters in Excel - Filter
  • In the field (below the Text Filter option), type A*Excel Wildcard Characters - Filter Field
  • Click OK.

This will instantly filter the results and give you 3 names – ABC Ltd., Amazon.com, and Apple Stores.

Excel Wildcard Characters - Filter A

How does it work? – When you add an asterisk (*) after A, Excel would filter anything that starts with A. This is because an asterisk (being an Excel wildcard character) can represent any number of characters.

Now with the same methodology, you can use various criteria to filter results.

For example, if you want to filter companies that begin with the alphabet A and contain the alphabet C in it, use the string A*C. This will give you only 2 results – ABC Ltd. and Amazon.com.

If you use A?C instead, you will only get ABC Ltd as the result (as only one character is allowed between ‘a’ and ‘c’)

Note: The same concept can also be applied when using Excel Advanced Filters.

#2 Partial Lookup Using Wildcard Characters & VLOOKUP

Partial look-up is needed when you have to look for a value in a list and there isn’t an exact match.

For example, suppose you have a data set as shown below, and you want to look for the company ABC in a list, but the list has ABC Ltd instead of ABC.

Excel Wildcard Characters - Partial Lookup

You can not use the regular VLOOKUP function in this case as the lookup value does not have an exact match.

If you use VLOOKUP with an approximate match, it will give you the wrong results.

However, you can use a wildcard character within VLOOKUP function to get the right results:

Enter the following formula in cell D2 and drag it for other cells:

=VLOOKUP("*"&C2&"*",$A$2:$A$8,1,FALSE)

Excel Wildcard Characters - Vlookup with wildvard characters

How does this formula work?

In the above formula, instead of using the lookup value as is, it is flanked on both sides with the Excel wildcard character asterisk (*) – “*”&C2&”*”

This tells excel that it needs to look for any text that contains the word in C2. It could have any number of characters before or after the text in C2.

Hence, the formula looks for a match, and as soon as it gets a match, it returns that value.

3. Find and Replace Partial Matches

Excel Wildcard characters are quite versatile.

You can use it in a complex formula as well as in basic functionality such as Find and Replace.

Suppose you have the data as shown below:

Excel Wildcard Characters - Find and Replace Data

In the above data, the region has been entered in different ways (such as North-West, North West, NorthWest).

This is often the case with sales data.

To clean this data and make it consistent, we can use Find and Replace with Excel wildcard characters.

Here is how to do this:

  • Select the data where you want to find and replace text.
  • Go to Home –> Find & Select –> Go To. This will open the Find and Replace dialogue box. (You can also use the keyboard shortcut – Control + H).
  • Enter the following text in the find and replace dialogue box:
    • Find what: North*W*
    • Replace with: North-West Excel Wildcard Characters - Find and Replace fields
  • Click on Replace All.

This will instantly change all the different formats and make it consistent to North-West.

Excel Wildcard Characters - North West

How does this Work?

In the Find field, we have used North*W* which will find any text that has the word North and contains the alphabet ‘W’ anywhere after it.

Hence, it covers all the scenarios (NorthWest, North West, and North-West).

Find and Replace finds all these instances and changes it to North-West and makes it consistent.

4. Count Non-blank Cells that Contain Text

I know you are smart and you thinking that Excel already has an inbuilt function to do this.

You’re absolutely right!!

This can be done using the COUNTA function.

BUT… There is one small problem with it.

A lot of times when you import data or use other people’s worksheet, you will notice that there are empty cells while that might not be the case.

These cells look blank but have =”” in it. The trouble is that the

The trouble is that the COUNTA function does not consider this as an empty cell (it counts it as text).

See the example below:

Excel Wildcard Characters - COUNTA

In the above example, I use the COUNTA function to find cells that are not empty and it returns 11 and not 10 (but you can clearly see only 10 cells have text).

The reason, as I mentioned, is that it doesn’t consider A11 as empty (while it should).

But that is how Excel works.

The fix is to use the Excel wildcard character within the formula.

Below is a formula using the COUNTIF function that only counts cells that have text in it:

=COUNTIF(A1:A11,"?*")

This formula tells excel to count only if the cell has at least one character.

In the ?* combo:

  • ? (question mark) ensures that at least one character is present.
  • * (asterisk) makes room for any number of additional characters.

Note: The above formula works when only have text values in the cells. If you have a list that has both text as well as numbers, use the following formula:

=COUNTA(A1:A11)-COUNTBLANK(A1:A11)

Similarly, you can use wildcards in a lot of other Excel functions, such as IF(), SUMIF(), AVERAGEIF(), and MATCH().

It’s also interesting to note that while you can use the wildcard characters in the SEARCH function, you can’t use it in FIND function.

Hope these examples give you a flair of the versatility and power of Excel wildcard characters.

If you have any other innovative way to use it, do share it with me in the comments section.

You May Find the Following Excel Tutorials Useful:

DOWNLOAD FREE EXCEL EBOOK

51 Excel Tips to Save Time & Increase Productivity

(22,000+ Enthusiasts have Already Downloaded)

  • Ogundepo Ezekiel Adebayo

    Interesting! I read it through.

  • Ben

    Is there a way of using any of these find replace tricks to change a bunch of cells with an increasing value in them, in the format “Text_1_OtherText” to “Text_01_OtherText” without changing “Text_10_OtherText” to “Text_010_OtherText” ?

  • Brett Jones

    Thanks. Very helpful.

    • Thanks for commenting Brett.. Glad you liked it!

  • Hi Sumit,
    Really it is a detailed guide on using wildcards with Excel.
    I have also written a guide on the same topic. Would you please check it out and give your valuable comments?
    Here is the link of the article: http://www.exceldemy.com/how-to-use-wildcards-in-excel/