Have you ever played Scrabble? It is the game where you receive points for constructing words from letters printed on small plastic tiles. In my opinion, the best tile to get is always the blank tile. It doesn’t score any points, but it can be used to represent any letter at all. Therefore, if you have a blank tile in your rack of letters it becomes much easier to create words. Wildcard characters in Excel work in a similar way to the blank tile in Scrabble. But wildcards go just a little bit further; you can combine several blanks together, or even allow an unlimited number of blanks. When combined with VLOOKUP we can create a very powerful lookup/search feature.
Normally when using VLOOKUP we are trying to find an exact match; sometimes we are happy with an approximate match (i.e. the next closest match), but sometimes we want to find an even looser match – these are the circumstances in which we would use wildcards.
The 3 wildcard characters
Wildcard characters can be used instead of actual characters:
Question mark (?)
A ? can take the place of any single character. If we had the text “Ex?el” then the ? could be any character (just like the blank scrabble tile). So, the text could be “Excel”, “Exuel”, “Ex7el”, or any other letter in the place of the ??
It is also possible to combine multiple question marks (?) together. For example, ??? would represent any three characters, but it must be 3 characters, no less, no more.
A * represents any number of characters (even no characters). If we had the text “Ex*” then the matches could be “Excel”, “Exam”, “Explain”, or any other word starting with “Ex”, including just “Ex”.
This is not strictly a wildcard character. It is used before a ? or a * to indicate that the ? or * should not be used as a wildcard character. For example, “Ex~*” would only match “Ex*”, as the * is not treated as a wildcard character, but as a character in its own right.
Using wildcard characters with VLOOKUP
Let’s look at an example.
We have a list of trees and their prices.
The formula in E6 is:
This is a basic VLOOKUP calculation.
Cell E4 contains the value we are looking up. Where the lookup value is “White” there are no matches, therefore “#N/A” is returned.
We could change our formula to join an asterisk (*) to the end of the lookup value as follows:
This would change the lookup value to “White*”, which would return a value of 20.
We could also achieve this by changing the value in cell E4 to “White*”.
“White*” would match with any word starting with “White”, such as “White Spruce”. There is also a match for “White Willow”, but “White Spruce” is first in the list, so that is the value returned.
Using an asterisk (*) either side of the lookup value provides a match for any string where the text between the asterisks (*) is present.
Looking up “*Willow*” will return any word containing “Willow”
It is also possible to mix question marks (?) and asterisks (*), such as in the following example:
The ? can only be exchanged for a single character, but the * can represent any number of characters.
Other circumstances to use wildcard characters
Wildcard characters can be used whenever matching text strings, common functions might be HLOOKUP, MATCH, SEARCH, SUMIFS and SUMIF.
Wildcard characters can even be used when using the find functionality within Excel.
Download the Advanced VLOOKUP Cheat Sheet
Download the Advanced VLOOKUP Cheat Sheet. It includes most of the tips and tricks we’ve covered in this series, including faster calculations, multiple criteria, left lookup and much more.
Please download it and pin it up at work, you can even forward it onto your friends and co-workers.
The download is available to newsletter subscribers, click the button below to become a subscriber and download the file.
Other posts in the Mastering VLOOKUP Series
- How to use VLOOKUP
- VLOOKUP: What does the True/False statement do?
- VLOOKUP: How to calculate faster
- How to VLOOKUP to the left
- VLOOKUP: Change the column number automatically
- VLOOKUP with multiple criteria
- Using wildcards with VLOOKUP
- How to use VLOOKUP with columns and rows
- Automatically expand the VLOOKUP data range
- VLOOKUP: Lookup the nth item (without helper columns)
- VLOOKUP: List all the matching items
- Advanced VLOOKUP Cheat Sheet