When you want to pull information from a table, the Excel VLOOKUP function is a great solution.

And yet, although VLOOKUP is relatively easy to use, there is plenty that can go wrong.

Which you probably aren’t.

Overview of how VLOOKUP works

This can cause results thatlook completely normal, even though they aretotally incorrect.

How VLOOKUP works

VLOOKUP is a function to look up and retrieve data in a table.

(For horizontally structured data, seeHLOOKUP).

Overview of how VLOOKUP works

VLOOKUP requires that the table be structured so that lookup values appear in the left-most column.

The data you want to retrieve (result values) can appear in any column to the right.

When you use VLOOKUP, imagine that every column in the table is numbered, starting from the left.

Overview of how VLOOKUP works

You’ll also have to supply a smaller table to VLOOKUP that starts with the lookup column.

you’re free to overcome this limitation by using INDEX and MATCH instead of VLOOKUP.

To VLOOKUP, a product code like “PQRF” is identical to “pqrf”.

Overview of how VLOOKUP works

VLOOKUP has two matching modes

VLOOKUP has two modes of operation: exact match and approximate match.

In most cases, you’ll probably want to use VLOOKUP in exact match mode.

In these cases, you likely won’t find the exact lookup value in the table.

Overview of how VLOOKUP works

Instead, you want VLOOKUP to get you the best match for a given lookup value.

The formula in D5 does an approximate match to retrieve the correct commission:

6.

This name is not intuitive, so you’ll just have to memorize how it works.

VLOOKUP can only look to the right of the lookup value column

For an exact match, use FALSE or 0.

When doing an approximate match, VLOOKUP assumes the table is sorted and performs a binary search.

This is a clear indication that the value isn’t found in the table.

VLOOKUP always finds the first match

That way, you always have a visual reminder of the match mode you expect.

Video:How to use VLOOKUP for approximate matches

9.

Otherwise, you may getincorrect results.

VLOOKUP is NOT case-sensitive

Also be aware that sometimes text data maylooksorted, even though it’s not.

Felienne Hermanshas a great example of this problem here, from a cool analysis she did on actualEnronspreadsheets!

In the example below, we are using two VLOOKUP formulas.

VLOOKUP exact match example - matching movies

One to pull in the customer name, and the other to pull in the customer state.

Link:Example of merging with VLOOKUP.

Video:How to use VLOOKUP to merge tables.

VLOOKUP approximate match example - commissions

But you could also use VLOOKUP to assign arbitrary categories.

This is because hard-coded column index values don’t change automatically when columns are inserted or deleted.

The formula we are using is this:

16.

VLOOKUP merge data by joining tables -before

This is sometimes called a two-way lookup since you are looking up both the row and the column.

The trick is to use the MATCH function in place of a static column index.

See how in this quick video:How to do a two-way lookup with INDEX and MATCH.

VLOOKUP merge data by joining tables -after

This causes VLOOKUP to match the name “Monet”.

This is a useful error because VLOOKUP is telling you clearly that it can’t find thelookup_value.

The easiest way to trap errors with VLOOKUP is to wrap VLOOKUP in the IFERROR function.

VLOOKUP used to categorize - assigning grades

IFERROR allows you to “catch” any error and return a result of your choosing.

Here is the formula:

19.

If you are simply retrieving numbers as text from a column in a table, it doesn’t matter.

VLOOKUP used to categorize - assigning arbitrary groups

One way to do this is to convert the values in the lookup column to numbers.

An easy way to do this is toadd zero using paste special.

By contrast, VLOOKUP can assign the same grades with a simple formula.

Absolute references make VLOOKUP formulas more portable

All you better do is double-check the grade key table is set up for VLOOKUP (i.e.

it must be sorted by score, and contain brackets to handle all scores).

Video:How to replace nested IFs with VLOOKUP

21.

Named ranges make VLOOKUP formulas easier to read

However, there are ways to overcome this limitation.

How can we look up both at once?

You want an exact match because there’s a chance that an order number won’t be found.

Inserting a column in the table may break VLOOKUP

In this case, the exact match setting will cause VLOOKUP to return #N/A error.

Conversely, approximate matches are lightning fast because Excel is able to do what’s called abinary search.

The problem with binary searches however (i.e.

Example of using COLUMN to calculate the column index for VLOOKUP

Worse, the result might look completely normal, so it can be very difficult to spot.

The solution is to use VLOOKUP twice, both times in approximate match mode.

The first instance simply checks that the value really exists.

VLOOKUP two way lookup - how to lookup the month?

Note: Your data must be sorted to use this trick.

It’s simply a way to protect against a missing lookup value while maintaining a fast lookup.

It’s a very powerful combination.

VLOOKUP two way lookup using MATCH to get the column index

In straightforward situations, VLOOKUP will get the job done just fine with no fuss.

To learn more about INDEX and MATCH,see this article.

VLOOKUP with wildcards - using an asterisk directly

VLOOKUP with wildcards - asterisk is concatenated to the lookup value

VLOOKUP sporting an #N/A error

VLOOKUP #N/A error trapped with IFERROR

Numbers entered as text VLOOKUP error example

Numbers entered as text VLOOKUP error solution

Assigning grades with a long nested IF formula

Assigning grades with a simple VLOOKUP formula

VLOOKUP multiple criteria problem - how to look up on both first and last name?

VLOOKUP multiple criteria step 2 - add a helper column that joins multiple criteria

VLOOKUP multiple criteria step 3 - join criteria to form lookup value

Overview of how VLOOKUP works

VLOOKUP always finds the first match

VLOOKUP is NOT case-sensitive

VLOOKUP exact match example - matching movies

VLOOKUP merge data by joining tables -before

VLOOKUP merge data by joining tables -after

VLOOKUP used to categorize - assigning grades

Absolute references make VLOOKUP formulas more portable

Named ranges make VLOOKUP formulas easier to read

Inserting a column in the table may break VLOOKUP

Example of using COLUMN to calculate the column index for VLOOKUP

VLOOKUP two way lookup - how to lookup the month?

VLOOKUP two way lookup using MATCH to get the column index

VLOOKUP sporting an #N/A error

VLOOKUP #N/A error trapped with IFERROR

Numbers entered as text VLOOKUP error example

Numbers entered as text VLOOKUP error solution

VLOOKUP multiple criteria problem - how to look up on both first and last name?

VLOOKUP multiple criteria step 2 - add a helper column that joins multiple criteria

VLOOKUP multiple criteria step 3 - join criteria to form lookup value