Skip to content

Lesson 18 of 92 · Free Excel Course

Excel

Excel VLOOKUP: How to Look Up a Value in a Table (Plus HLOOKUP)

Learn VLOOKUP in Excel step by step: exact vs approximate match, lookups from another sheet, fixing #N/A and #REF!, and HLOOKUP. Free practice file.

You have a list of order codes and a separate price list, and you need the price next to each order. You could scroll and copy each one by hand, or let VLOOKUP do it. VLOOKUP looks for a value in the first column of a table and brings back something from the same row: the item name, the price, the stock count. It's one of the most-used functions in Excel, and once it clicks, you'll use it everywhere. This lesson walks through your first VLOOKUP, the difference between exact and approximate match, how to fix the errors everyone hits, and its sideways twin, HLOOKUP.

How a VLOOKUP formula is built

VLOOKUP takes four pieces of information, separated by commas:

=VLOOKUP(lookup_value, table_array, col_index_num, range_lookup)

  • lookup_value: what you're looking for, usually a cell like A2 holding a code or name.
  • table_array: the table to search, such as $G$2:$I$9. VLOOKUP always searches the first column of this range.
  • col_index_num: which column of the table to bring back, counting from 1 at the left of the table (not from column A of the sheet).
  • range_lookup: FALSE for an exact match, TRUE for an approximate match. It's optional, but if you leave it out Excel uses TRUE, which is rarely what you want for codes or names. Type FALSE every time unless you mean otherwise. You can also write 0 for FALSE and 1 for TRUE.

In plain words, =VLOOKUP(A2,$G$2:$I$9,3,FALSE) says: "find what's in A2 in the first column of G2:I9, and give me the value from the 3rd column of that row, exact matches only."

Your first VLOOKUP, step by step

Here, orders are in columns A and B and the price list is in G1:I9. Code A103 is in A2.

  1. Click C2, where the item name should go.
  2. Type =VLOOKUP( and click A2, then type a comma.
  3. Drag over G2:I9, the price list without its header row. Press F4 to add dollar signs, so it reads $G$2:$I$9, then type a comma. (On a Mac, press Cmd+T, or simply type the $ signs yourself.)
  4. Type 2 for the second column of the table (Item), a comma, then FALSE).
  5. Press Enter. C2 shows Stapler.
  6. In D2, type the same formula with 3 instead of 2: =VLOOKUP(A2,$G$2:$I$9,3,FALSE). It shows $12.00.
  7. Select C2:D2 and drag the fill handle down to row 4.
D2=VLOOKUP(A2,$G$2:$I$9,3,FALSE)
ABCDEFGHI
1CodeQtyItemPriceCodeItemPrice
2A1032Stapler$12.00A101Pens$4.50
3A10110Pens$4.50A102Notebook$3.25
4A1074Folders$5.10A103Stapler$12.00
5A104Tape$2.75
6A105Scissors$6.80
7A106Markers$8.40
8A107Folders$5.10
9A108Glue$1.95
VLOOKUP finds A103 in the first column of G2:I9 and returns the 3rd column of that row: $12.00.

This works the same on a Mac and in Excel for the web. Excel shows the argument names in a small tip as you type, so you can see which part you're on.

Exact match vs approximate match

With FALSE, VLOOKUP either finds the exact value or gives up with #N/A. That's what you want for codes, names, IDs and anything else that should match exactly. The table doesn't need to be sorted.

With TRUE (or nothing), VLOOKUP looks for the largest value that is less than or equal to your lookup value. That sounds odd until you need it for bands: grades, tax brackets, shipping rates, discounts. Here a score of 85 has no exact row, so VLOOKUP stops at 80, the biggest number not above 85, and returns B.

C12=VLOOKUP(B12,$G$12:$H$16,2,TRUE)
ABCDEFGH
11StudentScoreGradeMin scoreGrade
12Ana85B0F
13Ben59F60D
14Cy90A70C
15Dee72C80B
1690A
Approximate match on a sorted table: 85 falls in the 80 band (B), 59 in the 0 band (F), and 90 is an exact hit (A).

The rule that matters: for approximate match, the first column must be sorted from smallest to largest. Each row is the bottom of its band, and the table starts at 0 so every score has somewhere to land. A lookup value below the first row, such as -5, gives #N/A.

If the table isn't sorted, Excel doesn't warn you. It just returns a wrong answer that looks perfectly normal:

C12=VLOOKUP(B12,$G$12:$H$16,2,TRUE)
ABCDEFGH
11StudentScoreGradeMin scoreGrade
12Ana85C90A
130F
1480B
1560D
1670C
Same formula, unsorted table: Ana's 85 can come back as C instead of B, with no error to warn you.

Approximate match searches by jumping around the list rather than reading every row, so on unsorted data the answer depends on where it happens to land. Sort the band table (select it, then Data > Sort, smallest to largest) before you rely on TRUE.

Copy a VLOOKUP down: lock the table with $

When you copy a formula down, Excel shifts every cell reference by one row, as you saw in Absolute and relative references. That's right for the lookup value (A2 becomes A3), but wrong for the table: G2:I9 would become G3:I10, then G4:I11, and soon the top rows of your price list fall out of the range. Lookups near the bottom then show #N/A or the wrong item.

The fix is dollar signs: $G$2:$I$9 stays put wherever you copy it. Press F4 right after selecting the range to add them.

Look up from another sheet or workbook

Price lists usually live on their own sheet. The formula is the same, with the sheet name and an exclamation mark in front of the range:

=VLOOKUP(A2,Prices!$A$2:$C$50,3,FALSE)

  1. Type =VLOOKUP(, click A2 and type a comma.
  2. Click the Prices tab at the bottom.
  3. Drag over the table, press F4, and type ,3,FALSE).
  4. Press Enter. Excel jumps back to your first sheet with the answer.

If the sheet name has a space, Excel wraps it in single quotes: 'Price List'!$A$2:$C$50.

You can also look up in a different workbook. Open both files, start the formula, then switch to the other workbook and select the table. Excel writes the file name in square brackets, like [Prices.xlsx]Sheet1!$A$2:$C$50. When that file is closed, Excel shows its full folder path instead. The link breaks if the file is moved or renamed, so keep lookups inside one workbook when you can.

Fix common VLOOKUP errors

What you seeUsual causeFix
#N/AThe value really isn't in the table's first columnCheck spelling; wrap in IFNA (below) if missing values are expected
#N/A, but you can see the valueA hidden space, such as "A105 " with a space after itCompare =LEN(A6) with the table; use =VLOOKUP(TRIM(A6),...) or clean the data
#N/A on numbersOne side is a number stored as textLook for the green triangle, then Convert to Number
#REF!The column number is bigger than the table, such as 4 on a 3-column tableCount the table's columns again
Wrong value, no errorWrong column number, or TRUE on unsorted dataRecount the column; use FALSE or sort the table
Errors only lower downThe table range moved when copiedAdd $ signs: $G$2:$I$9

The "number stored as text" problem is the same one from Add and SUM: to VLOOKUP, the number 1001 and the text "1001" are different values. Also check that the lookup value is in the first column of the range you selected. If you selected the table starting one column too far left or right, nothing will match.

Hide #N/A with IFNA or IFERROR

Sometimes a missing value is normal, like a new product code that isn't in the price list yet. Wrap the lookup to show a friendly message instead:

=IFNA(VLOOKUP(A5,$G$2:$I$9,2,FALSE),"Not found")

IFNA only catches #N/A. IFERROR works the same way, =IFERROR(VLOOKUP(A5,$G$2:$I$9,2,FALSE),"Not found"), but catches every error, including a #REF! from a typo, which you'd rather see. For lookups, IFNA is usually the safer choice. Use "" instead of "Not found" to show a blank.

VLOOKUP can't look left

VLOOKUP always searches the leftmost column of the table and returns something to its right. If your codes are in column C and the names you want are in column A, VLOOKUP can't do it without rearranging the columns.

Microsoft now recommends XLOOKUP, which it describes as an improved version of VLOOKUP that works in any direction and uses an exact match by default. It's in Microsoft 365, Excel 2021 and later, and Excel for the web, but not Excel 2016 or 2019. The next lesson, XLOOKUP and INDEX MATCH, covers both XLOOKUP and the older INDEX and MATCH trick that looks left in any version.

HLOOKUP for tables that run across

HLOOKUP is VLOOKUP turned on its side. It searches the top row of a table and returns a value from a row below. The only change is the third argument, row_index_num:

=HLOOKUP(B22,$B$19:$E$20,2,FALSE)

With sizes S, M, L and XL across row 19 and prices $12.00, $14.00, $16.00 and $19.00 in row 20, looking up L returns $16.00 from the 2nd row of the table. The same rules apply: FALSE for exact, TRUE needs the top row sorted left to right, and a row number bigger than the table gives #REF!. Tables that run across are rare, which is why HLOOKUP is used far less than VLOOKUP. XLOOKUP replaces it too.

Try it yourself

Download the practice workbook and open the Practice sheet. Yellow cells are where you type.

  1. In C2 type =VLOOKUP(A2,$G$2:$I$9,2,FALSE) (Stapler) and in D2 the same with 3 ($12.00). Copy C2:D2 down to row 4.
  2. A5 holds A110, which isn't in the list. In C5, wrap the lookup in IFNA to show Not found.
  3. A6 says "A105 " with a trailing space. In C6 a plain VLOOKUP gives #N/A. In D6 type =VLOOKUP(TRIM(A6),$G$2:$I$9,3,FALSE) to get $6.80.
  4. In E2 type =VLOOKUP(A2,Stock!$A$2:$B$9,2,FALSE) to fetch the stock count from the Stock sheet (35). Copy it down to E4.
  5. In C12 type =VLOOKUP(B12,$G$12:$H$16,2,TRUE) and copy it down to C15: B, F, A and C.
  6. In B23 type =HLOOKUP(B22,$B$19:$E$20,2,FALSE) to price size L at $16.00.

Then try breaking things on purpose: change a 3 to 4 to see #REF!, or remove the $ signs and copy down. Check everything against the Answers sheet.

Common mistakes

  • Leaving out FALSE. Without it, VLOOKUP does an approximate match and can quietly return the wrong row.
  • Counting columns from A. The column number counts from the first column of your table, not the sheet. In $G$2:$I$9, column I is 3.
  • Forgetting the $ signs. The table slides down as you copy and lookups near the bottom fail.
  • Approximate match on unsorted data. No error, wrong answer. Sort the first column smallest to largest.
  • Hidden spaces and text-numbers. The value looks right but doesn't match. Use TRIM and Convert to Number.
  • Hard-coding the column number, then inserting a column. A new column inside the table shifts everything, but the 3 in your formula stays 3. Recheck lookups after changing the table's layout.
  • Including the header row. Not an error, but start the range on the first data row so a header can never match.

What's next

VLOOKUP pairs nicely with what you learned in Text functions, since TRIM and SUBSTITUTE clean the codes before you look them up. Next, XLOOKUP and INDEX MATCH shows the newer, more flexible way to look things up, including to the left. You can always return to the full Excel course. To show a friendly message instead of #N/A, see the IFNA function page.

Frequently asked questions

How do I use VLOOKUP in Excel?

Type =VLOOKUP(what to find, the table, which column to return, FALSE). For example =VLOOKUP(A2,$G$2:$I$9,3,FALSE) finds the code in A2 in the first column of G2:I9 and returns the matching value from the table's 3rd column. FALSE means exact match.

Why is my VLOOKUP returning #N/A when the value is there?

Usually the two values aren't really the same: one has an extra space, or one is a number and the other is a number stored as text. Check with =LEN(A2) for hidden spaces and use TRIM, or convert the text to numbers. Also make sure the value is in the first column of the table.

What does TRUE or FALSE mean at the end of VLOOKUP?

FALSE (or 0) means exact match: find this value or show #N/A. TRUE (or 1) means approximate match: find the largest value that is less than or equal to it, which needs the first column sorted smallest to largest. If you leave it out, Excel uses TRUE, so type FALSE for normal lookups.

How do I do a VLOOKUP from another sheet?

Put the sheet name and an exclamation mark before the range: =VLOOKUP(A2,Prices!$A$2:$C$50,3,FALSE). The easy way is to type =VLOOKUP(A2, then click the other sheet's tab and drag over the table. If the sheet name has spaces, Excel adds single quotes, like 'Price List'!$A$2:$C$50.

Can VLOOKUP look to the left?

No. VLOOKUP only searches the first column of the table and returns values from columns to its right. To look left, use XLOOKUP or INDEX and MATCH, covered in XLOOKUP and INDEX MATCH.

Should I use VLOOKUP or XLOOKUP?

Microsoft calls XLOOKUP an improved version of VLOOKUP: it works in any direction and does an exact match by default. Use XLOOKUP if everyone opening the file has Excel 2021 or later, Microsoft 365 or Excel for the web. VLOOKUP is still worth knowing because it works in every version and you'll meet it in older files.