This post may contain affiliate links. Please read my disclosure for more info:

Using wildcards with VLOOKUP

vlookup formula

VLOOKUP with wildcards

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.

Asterisk (*)

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”.

Tilde (~)

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.

VLOOKUP wildcards

Example 1

The formula in E6 is:

=VLOOKUP(E4,A2:B11,2,0)

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:

=VLOOKUP(E4&"*",A2:B11,2,0)

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*”.

VLOOKUP wildcards *

“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.

Example 2

Using an asterisk (*) either side of the lookup value provides a match for any string where the text between the asterisks (*) is present.

VLOOKUP wildcards * twice

Looking up “*Willow*” will return any word containing “Willow”

Example 3

It is also possible to mix question marks (?) and asterisks (*), such as in the following example:

VLOOKUP wildcards ? and *

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

The Advanced VLOOKUP Cheat Sheet includes most of the tips and tricks covered in the Mastering VLOOKUP Series. Download it and pin it up at work; you can even forward it onto your friends and co-workers.

Advanced VLOOKUP Cheat Sheet

Existing newsletter subscribers can enter their name and e-mail address into the form below for instant access to the download.  Or, to access the download you can also enter your name and e-mail address below to become a subscriber.







 

Other posts in the Mastering VLOOKUP Series

eries.

Save

Leave a Reply

Your email address will not be published. Required fields are marked *