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 lifesavers.
This Tutorial Covers:
ToggleExcel Wildcard Characters – An Introduction
Wildcards are special characters that can take any place of any character (hence the name – wildcard).
There are three wildcard characters in Excel:
- * (asterisk) – It represents any number of characters. For example, Ex* could mean Excel, Excels, Example, Expert, etc.
- ? (question mark) – It represents one single character. For example, Tr?mp could mean Trump or Tramp.
- ~ (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:
- Filtering data using a wildcard character.
- Partial Lookup using wildcard character and VLOOKUP.
- Find and Replace Partial Matches.
- 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:
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
- In the field (below the Text Filter option), type A*
- Click OK.
This will instantly filter the results and give you 3 names – ABC Ltd., Amazon.com, and Apple Stores.
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.
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)
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.
Also read: Remove Asterisk (*) in Excel
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:
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
- Click on Replace All.
This will instantly change all the different formats and make it consistent to 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.
Also read: Check IF Cell Contains Partial Text in Excel
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:
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:
14 thoughts on “Excel Wildcard Characters – What are these and How to Best Use it”
I have been using Wildcard Characters since long, however you have given me new dimensions to imagine the use of Wildcard characters
Your Initial example using A*C will give two results is incorrect as it starts with A (ABC ltd.) but does not end with C. You should have used A*C*
Thank you!!
Hi Sumit,
Thank you for this wonderful information. I would like to know how to clear cells of notes, formulas, and spaces when using numbers and some letter/number combinations in the same worksheet. The spaces may be before or after the number or letter/number combinations. When I tried to replace the spaces with no space it just put the * or ? and removed the number. Thanks!!
Hi Sumit! Thank you so much for writing such an informative tutorial. I would like to know, how to find a name that ends with “y”. Because when I use “*y”, Excel displays all the names that have “y” in it.
go to text filters, select ‘ends with’
I have the following problem.
1. Excel document contains 1000 rows with URI patterns in Column A
– a. website.com/path1/######
– b. website.com/path1/######/path2
– c. website.com/path1/######?query
– d. website.com/path1/######/path2?query
– e. website.com/path1/path2/######
– f. website.com/path1/path2/######/path3
– g. website.com/path1/path2/######?query
– h. website.com/path1/path2/######/path3?query
2. I must extract the “/#######” pattern (exactly 8 characters) in column B as a single formula.
3. I tried various wildcard lookups / find / search /array / match with only partial success.
How do I wildcard match ONLY numeric values, exclude ALPHABET values, only wildcard of ??????? (7 number string) wild card?
Mate, if all you need for all the 1000 rows is all the time the 1st 8 characters of the cells in column A, then your formula in B1 can be =LEFT(A1,8). This extracts the 1st 8 characters from your original string
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/
Thanks. Very helpful.
Thanks for commenting Brett.. Glad you liked it!
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” ?
Interesting! I read it through.