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

Inserting the Subject in Your Document

One of the properties you can specify for a document is a subject. You can then use a field code to insert this subject, ...

Discover More

Conditionally Highlighting Cells Containing Formulas

Excel's conditional formatting feature allows you to create formats that are based on a wide variety of criteria. If you ...

Discover More

Highlighting Text Using the Keyboard Only

Highlighting text, using the Highlight tool, is a great way to mark up a document. Normally you need to use the toolbar ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (menu)

Returning a Weight and a Date

If you have two columns containing dates and weights from those dates, you may want to pick a date associated with a ...

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

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
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 8 - 5?

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.