Adjusting the VLOOKUP Function

Written by Allen Wyatt (last updated August 27, 2022)
This tip applies to Excel 97, 2000, 2002, and 2003


John has a lookup table of ascending numerical values in column A and corresponding text values in column B. When he uses the VLOOKUP function it returns the text value for the numerical value equal to or less than the specified lookup value. John really wants the first value equal to or greater than the lookup value.

There is no way to change how VLOOKUP does its work; it will always match to the value equal to or less than the lookup value. An option, though, is to modify the formula used to do the actual lookup. Consider the following formula, which assumes that the value you want to use for your lookup is in cell D1:

=IF(VLOOKUP(D1,$A$1:$A$10,1)=D1,VLOOKUP(D1,$A$1:$B$10,2),
INDEX($B$1:$B$10,1+MATCH(D1,$A$1:$A$10)))

If the value in D1 is an exact match to a value in column A, then the regular VLOOKUP formula is used. If it isn't, then VLOOKUP is abandoned in favor of the INDEX function in conjunction with the MATCH function.

If you are able to sort your data table in descending order, you can use a shorter formula:

=INDEX($A$1:$B$10,MATCH(D1,$A$1:$A$10,-1),2)

The MATCH function uses the D1 value to look for the smallest value that is great than or equal to that value. (This is what the -1 parameter specifies.) The MATCH function returns the row number of the proper row, and then this is used by INDEX to actually fetch the value.

Another interesting approach to the problem is to use the inverse of the lookup values as a control column that will be used to actually look up information from the data table. For instance, let's assume that your data table is in A1:B10, with the actual numerical values you use for the lookup in column A. You need to insert a column to the left of your data table. Into the first cell of this new column (now column A), insert the following formula:

=1/B1

This provides the inverse of the value in B1, and you can copy it down the cells in column A. Your data table now has three columns, A1:C10. Next, sort your data table based on this new column, in ascending order.

Now you make a slight modification to your lookup formula so that it looks up the inverse of what you want. Assuming that the value you want to use for your lookup is in cell E1, you would use the following formula:

=VLOOKUP(1/E1,$A$1:$C$10,3)

What you effectively end up with is the desired value, from column C, that is associated with the value in column B that is equal to or less than the value in E1.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3090) applies to Microsoft Excel 97, 2000, 2002, and 2003.

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

Understanding the If ... End If Structure

One of the most basic of programming structures is the conditional structure: If ... End If. This tip explains how this ...

Discover More

Formatting Text in Custom Document Properties

Word allows you to create custom document properties that stay with a document and can be inserted through the use of ...

Discover More

Understanding Relative and Absolute Addressing

In Excel you can reference a cell in a formula by entering the coordinates for the cell you want to reference. This can ...

Discover More

Best-Selling VBA Tutorial for Beginners Take your Excel knowledge to the next level. With a little background in VBA programming, you can go well beyond basic spreadsheets and functions. Use macros to reduce errors, save time, and integrate with other Microsoft applications. Fully updated for the latest version of Office 365. Check out Microsoft 365 Excel VBA Programming For Dummies today!

More ExcelTips (menu)

Making VLOOKUP Case Sensitive

The VLOOKUP function, like other lookup functions in Excel, is not case sensitive. In other words, it doesn't matter ...

Discover More

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

Using the COLUMN Function

Need to know the column number for use in a formula? The worksheet function you want is the COLUMN function, described in ...

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.