Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to vlookup the last or first matching value in Excel?

If you have a list of items which are repeated many times, and now, you just want to know the last matching value with your specified data. For example, I have the following data range, there are duplicate product names in column A but different order numbers in column B, and I want to return the last matching value 174 of the product KTE as following screenshot shown:

doc-lookup-last-match-1

Vlookup the last matching value in Excel with formulas

Vlookup the first matching value in Excel with Kutools for Excel


arrow blue right bubble Vlookup the first matching value in Excel with Kutools for Excel

Kutools for Excel collects multiple commonly used formulas, with them, you can quickly calculate age from a birthday, add years, months, weeks or days to a given date, vlookup and return the matching value from a table, and so on.

doc-lookup-last-match-1

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


arrow blue right bubble Vlookup the last matching value in Excel with formulas


To vlookup and return the certain value you need, the vlookup function will be first in your mind, but, with the vlookup function you just return the first matching value not the last. Here, I will talk about some other formulas to deal with this task.

Please enter this formula =LOOKUP(2,1/(A2:A12=D2),B2:B12) into your specified cell and press Enter key to get the last corresponding value as follows:

doc-lookup-last-match-1

Notes:

1. If there is no data in the last matching cell, you will get a result of 0, but that is not your need, you want the last non-zero value, in this case, you should use the following array formula: =LOOKUP(9.99999999999999E+307,IF(A2:A12=D2,IF(ISNUMBER(B2:B12),B2:B12))) and press Ctrl + Shift + Enter keys together.

doc-lookup-last-match-1

2. In the above formulas, A2:A12 indicates the column that you are looking for, D2 is the value which you want to return its relative information and B2:B12 is the list that contains the value you want to return.

3. The value you are looking for is not case sensitive.


Related articles:

How to use vlookup exact and approximate match in Excel?

How to vlookup values from right to left in Excel?

How to lookup value to match case sensitive in Excel?


Excel Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 70%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 80% Excel problems.

  • Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  • Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  • Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  • No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  • Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  • 60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  • Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Alaa · 4 months ago
    Thank you for the formula its genius
    I used your formula to come up with a fix for the blank cells without using CSE (Ctrl + Shift + Enter)
    =LOOKUP(3,(1/(A2:A12=D2))+(1/(B2:B12<>"")),B2:B12)
  • To post as a guest, your comment is unpublished.
    Mayank Channa · 1 years ago
    In the above formula "=LOOKUP(9.99999999999999E+307,IF(A2:A12=D2,IF(ISNUMBER(B2:B12),B2:B12)))" why that "9.99999999999999E+307" has been taken in this?
  • To post as a guest, your comment is unpublished.
    Megan · 1 years ago
    Is there any way to combine this with TEXT values, which are in another sheet?
  • To post as a guest, your comment is unpublished.
    Mike Jones · 1 years ago
    Thanks, this is brilliant
  • To post as a guest, your comment is unpublished.
    Magil · 1 years ago
    Oh. My God. How that. Impressed.. :)