Skip to main content

How to vlookup and return the last matching value in Excel?

Author: Xiaoyang Last Modified: 2025-04-08

In Excel, the VLOOKUP function is commonly used to search for and retrieve data from a table. However, by default, "VLOOKUP" only returns the first matching value it finds. What if you need to return the last matching value instead? To achieve this, we use alternative formulas with functions like "LOOKUP", "XLOOKUP", "NDEX", "MATCH" or "Kutools". We’ll also explore how to optimize these methods for better performance and usability.


Vlookup and return the last matching value with LOOKUP function

The "LOOKUP" function is a powerful tool in Excel that can be used to find the last matching value in a dataset.

Please enter the following formula into your specified cell, and then drag the fill handle down to the cells to get the last corresponding value as follows:

=LOOKUP(2,1/($A$2:$A$12=E2),$C$2:$C$12)
 Vlookup the last matching value with LOOKUP function
In the formula:
  • "A2:A12" is the range containing the lookup column;
  • "E2" is the cell containing the value to look up;
  • "C2:C12" is the range containing the return values.
Explanation of the formula:
  • "1/($A$2:$A$12=E2)" creates an array of #DIV/0! errors and 1 where the condition is met.
  • "LOOKUP(2,...)" scans for the last 1 in the array, effectively finding the last match.

Vlookup and return the last matching value with Kutools for Excel

"Kutools for Excel" provides an easy and efficient way to perform advanced lookups, including returning the last matching value from a dataset. Follow these steps to achieve this without complex formulas.

Kutools for Excel offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Itegarate with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

After installing Kutools for Excel, please do as this:

1. Click "Kutools" > "Super LOOKUP" > "LOOKUP from Bottom to Top", see screenshot:

Click Kutools > Super LOOKUP > LOOKUP from Bottom to Top

2. In the "LOOKUP from Bottom to Top" dialog box, please do the following operations:

  • Select the lookup value cells and output cells from the "Output Range and Lookup values" sections;
  • Then, specify the corresponding items from the "Data range" section.
  • Finally, click "OK" button.
    specify options in the dialog box

Then, all the last matching items have been returned at once, see screenshot:

all the last matching items are returned by kutools

Tip:

If you want to replace the #N/A error value with another text value, you just need to click "Options" button and  check "Replace #N/A error value with a specified value" option,  then type the text you need.
 Replace #N/A error value with a specified value option


Vlookup and return the last matching value with INDEX and MATCH functions

While the traditional VLOOKUP function doesn't support this functionality, you can combine the powerful "INDEX" and "MATCH" functions to achieve it. This method is dynamic, efficient, and works across all Excel versions.

Please enter the following formula into your specified cell, press "Ctrl" + "Shift" + "Enter" key in Excel 2019 and earlier versions, press "Enter" key directly in Excel 365, Excel 2021 and later versions.

=INDEX($C$2:$C$12,MATCH(2,1/($A$2:$A$12=E2)))

Then drag the fill handle down to the cells to get the last corresponding value as follows:

 Vlookup the last matching value with INDEX and MATCH functions
In the formula:
  • "A2:A12" is the range containing the lookup column;
  • "E2" is the cell containing the value to look up;
  • "C2:C12" is the range containing the return values.
Explanation of the formula:
  • "1/($A$2:$A$12=E2)" creates an array of #DIV/0! errors and 1 where the condition is met.
  • "MATCH(2, 1/($A$2:$A$12=E2))"  looks for the number 2 in the array created by 1/($A$2:$A$12=E2). Since 2 isn’t in the array, MATCH finds the position of the last valid 1, which corresponds to the last matching row in $A$2:$A$12.
  • "INDEX($C$2:$C$12,...)" uses the row number from MATCH to retrieve the corresponding value from $C$2:$C$12.

Vlookup and return the last matching value with XLOOKUP function

The XLOOKUP function, introduced in Excel 365, 2021 and later versions, is a powerful and versatile replacement for "VLOOKUP" and "HLOOKUP". One of its key features is the ability to perform lookups in reverse order, making it perfect for finding the last matching value in a dataset.

Please enter the following formula into your specified cell, and then drag the fill handle down to the cells to get the last corresponding value as follows:

=XLOOKUP(E2, $A$2:$A$12, $C$2:$C$12, , , -1)
 Vlookup the last matching value with LOOKUP function
In the formula:
  • "E2": The lookup value;
  • "A2:A12": The lookup array, i.e., the range where the function searches for the lookup value;
  • "C2:C12": The return array, i.e., the range from which the corresponding value is returned;
  • ,,: These two commas represent optional arguments for if_not_found and match_mode. We leave them empty in this case.
  • "-1": Specifies the search mode to start searching from the bottom of the range.

Returning the last matching value in Excel can be achieved using a variety of methods, depending on your needs and the version of Excel you’re using. Each method has its own strengths, and your choice should depend on the Excel version you have. By mastering one or more of these techniques, you’ll significantly enhance your data management skills and streamline your workflow in Excel. If you're interested in exploring more Excel tips and tricks, our website offers thousands of tutorials.


More relative articles:

  • Vlookup Values Across Multiple Worksheets
  • In excel, we can easily apply the vlookup function to return the matching values in a single table of a worksheet. But, have you ever considered that how to vlookup value across multiple worksheet? Supposing I have the following three worksheets with range of data, and now, I want to get part of the corresponding values based on the criteria from these three worksheets.
  • Use Vlookup Exact And Approximate Match In Excel
  • In Excel, vlookup is one of the most important functions for us to search a value in the left-most column of the table and return the value in the same row of the range. But, do you apply the vlookup function successfully in Excel? This article, I will talk about how to use the vlookup function in Excel.
  • Vlookup To Return Blank Or Specific Value Instead Of 0 Or N/A
  • Normally, when you apply the vlookup function to return the corresponding value, if your matching cell is blank, it will return 0, and if your matching value is not found, you will get an error #N/A value as below screenshot shown. Instead of displaying the 0 or #N/A value, how can you make it show blank cell or other specific text value?
  • Vlookup And Concatenate Multiple Corresponding Values In Excel
  • As we all known, the Vlookup function in Excel can help us to lookup a value and return the corresponding data in another column, but in general, it can only get the first relative value if there are multiple matching data. In this article, I will talk about how to vlookup and concatenate multiple corresponding values in only one cell or a vertical list.

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!