How to Write a VLOOKUP in Excel: Step by Step
In this article
- How Do You Write a VLOOKUP?
- What Each Part of the VLOOKUP Means?
- How Do You Know the VLOOKUP Worked?
- Why Does VLOOKUP Return #N/A?
- Exact Match or Approximate Match?
- A Worked Example with Real Cell References
- Which Lookup Settings Fit Which Job?
- Can VLOOKUP Look to the Left?
- Does VLOOKUP Work in Google Sheets?
A VLOOKUP finds a value in the first column of a table and returns whatever sits in a column to its right: =VLOOKUP(A2, D:F, 3, FALSE). Type it into a cell, fill it down, and you have matched data in a couple of minutes.
Time 5 min · Steps 6 · Level Easy
How Do You Write a VLOOKUP?
- Put your lookup value in a cell. For example, type a product code like P-104 into cell A2, or make sure the codes you want to look up already sit in column A.
- Start the formula. Click the cell where you want the answer, type =VLOOKUP( and click cell A2 so its reference appears, then type a comma.
- Select the table you are searching. Drag over the lookup table, for example D2:F50, then press F4 to make it absolute so it reads $D$2:$F$50, and type another comma. The value you are searching for must be in the first column of this range.
- Enter the column number. Count columns from the left of your selected range: if the answer you want is in the third column of D:F, type 3, then a comma.
- Type FALSE and close the bracket. FALSE (or 0) forces an exact match, which is what you want almost every time. The finished formula reads =VLOOKUP(A2,$D$2:$F$50,3,FALSE). Press Enter.
- Fill the formula down. Click the cell with the formula, then drag the small square at its bottom-right corner down the rows you need, or double-click that square to fill to the bottom of your list.
What Each Part of the VLOOKUP Means?
The formula has four arguments, separated by commas: lookup_value is what you are searching for; table_array is the range holding both the search column and the answer column; col_index_num is how many columns from the left of that range the answer sits in; and range_lookup is TRUE for an approximate match or FALSE for an exact one. The counting rule trips people up most: if your range starts at column D, then D is column 1, E is 2 and F is 3, no matter what the spreadsheet's column letters say.
How Do You Know the VLOOKUP Worked?
A working VLOOKUP returns the value from your table, and it updates automatically if you change the lookup value or the table entry. Test it by changing the value in A2 to a code you know exists in the table; the result should change instantly. If you get the right answer for the first row, fill down and spot-check two or three rows in the middle and at the bottom of your list.
Why Does VLOOKUP Return #N/A?
#N/A means Excel could not find your lookup value, and the most common cause is invisible extra spaces. Fix it by wrapping the lookup value in TRIM: =VLOOKUP(TRIM(A2),$D$2:$F$50,3,FALSE). Other causes: the value is text in one place and a number in the other (numbers stored as text often show a small green triangle in the cell), the lookup column is not the first column of your selected range, or the value genuinely is not in the table. If you want a blank instead of #N/A, wrap the whole thing in IFERROR: =IFERROR(VLOOKUP(A2,$D$2:$F$50,3,FALSE),"").
Exact Match or Approximate Match?
Use FALSE for exact matches, which covers nearly all everyday cases: product codes, names, employee IDs. Use TRUE only for banded lookups where you want the nearest lower value, such as tax brackets or shipping rates by weight, and in that case the first column of your table must be sorted in ascending order. If you use TRUE with unsorted data, you get wrong answers rather than an error, which is worse.
A Worked Example with Real Cell References
Suppose sheet data has product codes in D2:D40, prices in E2:E40 and stock counts in F2:F40. In a summary sheet, codes sit in A2:A20 and you want the price next to each one. In B2 you type =VLOOKUP(A2,Data!$D$2:$F$40,2,FALSE) and press Enter; 2 pulls the price from column E. In C2 you type the same formula with 3 instead of 2 to pull the stock count from column F. Fill both down to row 20 and every code with a match shows its price and stock; codes missing from the table show #N/A.
Which Lookup Settings Fit Which Job?
| Job | Fourth argument | Table must be sorted? |
|---|---|---|
| Match an ID, code or name | FALSE | No |
| Match a price band or tax bracket | TRUE | Yes, ascending by first column |
| Hide errors in a report | FALSE inside IFERROR | No |
| Search text that may have stray spaces | FALSE with TRIM | No |
Can VLOOKUP Look to the Left?
No, and this is its main limit: VLOOKUP only searches the first column of the range you give it and can only return values from columns to the right. If the answer column sits to the left of your search column, either rearrange the data, or use INDEX and MATCH instead: =INDEX(D2:D40,MATCH(A2,F2:F40,0)) returns a value from column D by matching in column F. XLOOKUP, available in newer Excel versions, does the same job with a simpler syntax and searches in any direction; the exact menu and function names can differ slightly between versions.
Does VLOOKUP Work in Google Sheets?
Yes, the syntax is identical: =VLOOKUP(A2,$D$2:$F$50,3,FALSE) works the same way in Google Sheets, with the same FALSE for exact matches and the same #N/A error when nothing matches. Sheets also accepts the words TRUE and FALSE or the numbers 1 and 0 interchangeably, and IFERROR and TRIM work the same way for cleaning up results.
Official source: Microsoft Support