Software & OS

How to Use VLOOKUP in Excel (Syntax, Examples, Fixes)

To use VLOOKUP in Excel, type =VLOOKUP(lookup_value, table_array, col_index_num, FALSE): it finds the value in the first column of a range and returns the value from the column number you choose in the same row. Always end with FALSE unless you specifically want an approximate match.

The VLOOKUP syntax

=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
ArgumentRequiredWhat it is
lookup_valueYesThe value to find. It is searched for in the first column of table_array. Can be a value or a cell reference.
table_arrayYesThe range that holds both the lookup column and the column you want back. Can be a named range or a table.
col_index_numYesThe column of the result, counted from the left edge of table_array, which is column 1.
range_lookupNoFALSE (or 0) for an exact match, TRUE (or 1) for an approximate match. If you leave it out, it is TRUE.

Example: find a price by product ID

Say your data is in A2:C5, with the headers in row 1:

A (ID)B (Product)C (Price)
2101Notebook3.50
3102Pen1.20
4103Stapler8.90
5104Tape2.75

To get the product name for the ID typed in E2:

=VLOOKUP(E2,$A$2:$C$5,2,FALSE)

If E2 holds 103, the result is Stapler (example output). Change the column number to 3 and the same formula returns the price, 8.90. The $ signs lock the range, so the formula still points at the same table when you fill it down a column.

To check your work, look at the table above: ID 103 sits in row 4 of the sheet, and column 2 of the range holds the product name, so the formula returns the name from that same row. If you type an ID that isn't in the list, such as 999, the exact-match formula returns #N/A, which tells you the lookup failed rather than guessing a nearby row.

Two habits prevent most mistakes. First, count col_index_num from the first column of the range you selected, not from column A of the sheet. If the range were B2:C5, the price would be column 2, not 3. Second, keep the lookup column at the far left of the range, because VLOOKUP cannot search any other column.

Exact match or approximate match

The last argument changes what VLOOKUP does:

  • FALSE (exact): looks for exactly the value you gave. If it isn't there, you get #N/A. The first column does not need to be sorted.
  • TRUE or omitted (approximate): finds the closest value that is not larger than yours. Microsoft states this assumes the first column is sorted, in ascending order. On unsorted data you can get a wrong result with no error.

Approximate match is meant for ranges such as tax bands or grade boundaries. For IDs, names and codes, use FALSE.

Use wildcards with text

When range_lookup is FALSE and the lookup value is text, you can use wildcards:

  • ? matches any single character.
  • * matches any run of characters.
  • ~ before a character finds a literal ? or *.

Microsoft's example is =VLOOKUP("Fontan?",B2:E7,2,FALSE), which matches "Fontana" or any other seven-letter word starting with "Fontan".

Fix VLOOKUP errors

ErrorCauseFix
#N/AExact match: the value is not in the first column. Approximate match: the value is smaller than every value in the first column.Check spelling and spaces. Make sure numbers aren't stored as text. Use TRIM or CLEAN on the data if it has stray spaces or nonprinting characters.
#REF!col_index_num is larger than the number of columns in table_array.Widen the range or lower the column number.
#NAME?Usually missing quotation marks around text, such as "Fontana".Put the text in quotes.
#SPILL!Usually a whole column used as the lookup value, such as =VLOOKUP(A:A,A:C,2,FALSE).Use a single cell, such as =VLOOKUP(A2,A:C,2,FALSE).

Wrong values with no error usually come from an unsorted first column combined with an approximate match.

Show a message instead of #N/A

Wrap the formula in IFERROR, which returns a value of your choice when the formula produces an error:

=IFERROR(VLOOKUP(E2,$A$2:$C$5,2,FALSE),"Not found")

IFERROR hides every error type, including #REF! and #NAME?, so a typo in the formula would also show "Not found". Test the formula without the wrapper first.

VLOOKUP limits, and XLOOKUP

VLOOKUP only searches the first column of the range and returns from a column to its right. If the value you want sits to the left of the lookup column, VLOOKUP can't reach it. Its replacement, XLOOKUP, takes the search column and the result column as two separate ranges:

=XLOOKUP(E2,A2:A5,B2:B5)

XLOOKUP defaults to an exact match and returns #N/A when nothing is found. Microsoft lists it for Microsoft 365, Excel 2021 and Excel 2024, and notes that it isn't available in Excel 2019 or 2016. On those versions, keep using VLOOKUP.

Frequently asked questions

What do the four VLOOKUP arguments mean?
lookup_value is what you search for, table_array is the range to search, col_index_num is the column number in that range to return (the leftmost column is 1), and range_lookup is FALSE for an exact match or TRUE for an approximate match. range_lookup is optional and defaults to TRUE.
Why does VLOOKUP return #N/A?
With an exact match, the value was not found in the first column of the table. Common reasons are extra spaces, numbers stored as text, or a real mismatch. With an approximate match, the value is smaller than the smallest value in the first column.
Can VLOOKUP look to the left?
No. It searches only the first column of table_array and returns from a column to the right of it, counting the first column as 1. To return a value from the left of the lookup column, use XLOOKUP, or rearrange the columns.
Should I use VLOOKUP or XLOOKUP?
Microsoft describes XLOOKUP as an improved version of VLOOKUP that works in any direction, and it defaults to an exact match. XLOOKUP is not available in Excel 2019 or 2016, so VLOOKUP is still the option in those versions.

Sources