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.
Download the cheat sheet
Download the file: Advanced VLOOKUP Cheat Sheet
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
If you’ve found this post useful, or if you have a better approach, then please leave a comment below.
Do you need help adapting this to your needs?
I’m guessing the examples in this post didn’t exactly meet your situation. We all use Excel differently, so it’s impossible to write a post that will meet everybody’s needs. By taking the time to understand the techniques and principles in this post (and elsewhere on this site) you should be able to adapt it to your needs.
But, if you’re still struggling you should:
- Read other blogs, or watch YouTube videos on the same topic. You will benefit much more by discovering your own solutions.
- Ask the ‘Excel Ninja’ in your office. It’s amazing what things other people know.
- Ask a question in a forum like Mr Excel, or the Microsoft Answers Community. Remember, the people on these forums are generally giving their time for free. So take care to craft your question, make sure it’s clear and concise. List all the things you’ve tried, and provide screenshots, code segments and example workbooks.
- Use Excel Rescue, who are my consultancy partner. They help by providing solutions to smaller Excel problems.
Don’t go yet, there is plenty more to learn on Excel Off The Grid. Check out the latest posts: