Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Returning Blanks or Asterisks from a Lookup.

Returning Blanks or Asterisks from a Lookup

Written by Allen Wyatt (last updated May 19, 2018)
This tip applies to Excel 97, 2000, 2002, and 2003


Bob asked if there was a way to use VLOOKUP to return blanks or asterisks if the function cannot make a match in a lookup table.

Yes, this can be done, but not without making your formula just a bit more complex. The trick is to remember that VLOOKUP can operate in one of two ways. By default, it returns the next lower value to the one being looked for, if the data table is in ascending order and if there isn't an exact match. However, you can force VLOOKUP to only return exact matches, if desired. Consider the following example:

=VLOOKUP(5,A1:B10,2,FALSE)

This example searches through the lookup table (A1:B10) looking for the value 5 in the first column of the table. If it is found, then the corresponding value from the second column is returned. If it is not found, then VLOOKUP returns an #N/A error, indicating it could not locate the value. (The FALSE value as the fourth parameter indicates you don't want approximate matches.)

The key, then, is to play off this #N/A value and build what you want returned if there isn't a match. The following formula will return a series of five asterisks if there wasn't a match in the lookup:

=IF(ISNA(VLOOKUP(5,A1:B10,2,FALSE)),"*****",VLOOKUP(5,A1:B10,2,FALSE))

The ISNA function is used to test if the result of VLOOKUP is the #N/A error. If it is, then the asterisks are returned; if not, then the lookup value is returned. If you want the formula to return "nothing," then you can use this variation:

=IF(ISNA(VLOOKUP(5,A1:B10,2,FALSE)),"",VLOOKUP(5,A1:B10,2,FALSE))

This version returns a blank string if there was not a match in the lookup table. For some uses, this may not be exactly what you want. You may find it more appropriate to return a zero, and then hide zeroes in the worksheet (Tools | Options | View tab | clear the Zero Values check box). If you'd like a zero returned, then it takes only one change:

=IF(ISNA(VLOOKUP(5,A1:B10,2,FALSE)),0,VLOOKUP(5,A1:B10,2,FALSE))

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3335) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Returning Blanks or Asterisks from a Lookup.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Avoiding Scientific Notation on File Imports

When importing information from a CSV file, you may get unintended results from time to time. Here's how to force Excel ...

Discover More

Changing Your Windows 8 Account Picture

Want to personalize your Windows 8 experience a bit more? One way is by attaching a picture to your account, as discussed ...

Discover More

Ignoring Special Characters when Double-Clicking

If a word contains a special character within it, Excel actually thinks the single word is two words. This tip examines ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (menu)

Understanding the VLOOKUP Function

Functions are at the heart of Excel's power in working with data. One of the most misunderstood functions provided by ...

Discover More

Looking Up Names when Key Values are Identical

Need to look up some values based upon some key items that may be identical to each other? Depending on the ...

Discover More

Calculating Future Workdays

Need to calculate the date that is a certain number of workdays in the future? You can do so using a couple of different ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is five more than 3?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.