Depending on your needs, FILTER might be a better option than first or last match.

Read on for the answer and more interesting examples.

It doesn’t matter if data is sorted or not.

VLOOKUP which match will we get?

In the screen below, the lookup value in E5 is “red”.

In the screen below, VLOOKUP is set to approximate match mode, and colors are sorted.

With unsorted data, you may see normal-looking results that are totally incorrect.

VLOOKUP which match will we get?

This problem is more likely with VLOOKUP becauseVLOOKUP defaults to approximate matchwhen no fourth argument is provided.

To illustrate this problem, see the example below.

Data isunsortedand VLOOKUP, with no fourth argument provided, defaults to approximate match.

VLOOKUP which match will we get?

We’ll look at how to overcome the problem of last match and unsorted data below.

If so, don’t worry.

Using approximate match to get the last match is not the “normal” case.

VLOOKUP which match will we get?

Typically, you’ll see approximate match used to assign values according to some kind of scale.

Practical applications

How can we use the behavior described above in a practical situation?

For example, below we are using VLOOKUP in approximate match mode to find the latest price for Sandals.

VLOOKUP which match will we get?

Below, we are using an equivalentINDEXandMATCHformula find the latest price with the same data.

LOOKUPalwaysperforms an approximate match, so it works well in “last match” scenarios.

This means we can dynamically build a lookup array to locate the data we want using simple logical expressions.

VLOOKUP exact match finds first match

You may not have seen a formula like this before, so let’s break it down in steps.

This may seem puzzling.

How will LOOKUP ever find the number 2 in an array that contains only 1s and errors?

VLOOKUP approximate match finds last match

We are using 2 as a lookup value to force LOOKUP to scan to theend of the data.

The LOOKUP function will automatically ignore errors, so the only thing left to match are the 1s.

It will scan through the 1s looking for a 2 that will never be found.

Example of VLOOKUP approximate match wrong result

However, you’re free to certainly use an array formula if you like.

Also, the newerXMATCH functionandXLOOKUP functioncan be directly configured to return the last match.

Last non-blank cell

The approach above turns out to be really useful.

VLOOKUP approximate match to assign grades

Lookup nth match?

Here are some links for you:

You’ll notice formulas like this get complicated.

There are some cool new functions coming to Excel in 2019 that will make these solutions much simpler.

VLOOKUP approximate match + sorted data = latest price

In the meantime, don’t forget thatPivot Tablesare a great way to explore datawithout formulas.

What’s next?

Below are guides to learn more about Excel formulas.

INDEX and MATCH approximate to find latest price

We also offeronline video training.

LOOKUP function to find latest price

LOOKUP function to find last match with unsorted data

Using LOOKUP to find the last non-blank cell

VLOOKUP which match will we get?

VLOOKUP exact match finds first match

VLOOKUP approximate match finds last match

Example of VLOOKUP approximate match wrong result

VLOOKUP approximate match to assign grades

VLOOKUP approximate match + sorted data = latest price

INDEX and MATCH approximate to find latest price

LOOKUP function to find latest price

LOOKUP function to find last match with unsorted data

Using LOOKUP to find the last non-blank cell