A VLOOKUP generator writes the formula for you from four answers: what to look for, where to look, which column to bring back, and whether the match must be exact. The usual job is an order sheet with product codes in column A and a price list on a sheet called Products, where each order row needs its unit price. Type A2, Products!A2:D100 and 3, and the generator gives you =VLOOKUP(A2,Products!$A$2:$D$100,3,FALSE).
How to use the VLOOKUP generator
- Type the lookup value. Usually that's the first cell of the codes you're looking up, like
A2. A number or a piece of text works too, and text gets its quotes added.
- Type the table array, for example
Products!A2:D100. "Lock the range with $" is ticked by default. Leave it on.
- Type the column index: which column of the table to return. Count from the table's first column, which is 1, not from column A of the sheet.
- Pick exact match (FALSE, the default) or approximate match (TRUE).
- To show something other than #N/A for codes missing from the table, tick "Wrap in IFERROR" and type the fallback. Leave it blank for an empty-looking cell.
- Read the formula, which changes as you type, and the line under it explaining each argument. Click "Copy formula", paste into the first result cell (say
E2), and fill down.
The formula is built in your browser. Nothing you type is uploaded, and there's no sign-up or usage limit.
What the generator does with each field
The generator takes what you'd type and fixes the parts that go wrong when a formula is written by hand.
| You type | The formula gets | Why |
|---|
a2 | A2 | Cell references go in as typed, with the column letters capitalised |
42 or TRUE | 42 or TRUE | Numbers and TRUE/FALSE aren't quoted |
Widget | "Widget" | Text needs double quotes inside a formula |
6" pipe | "6"" pipe" | A quote inside text has to be doubled |
"Widget" | "Widget" | Text you already quoted is kept |
=Products | Products | A leading = passes a defined name or expression through as written |
A2:D100 | $A$2:$D$100 | With the lock ticked, every column and row gets a $ |
Products or Sales[Region] in the table array | unchanged | Defined names and table references don't need $ |
Two catches in that table. A bare word in the lookup value field counts as text: Products there becomes "Products", so type =Products if you mean a defined name. And a product code shaped like a cell address, such as XL200, goes in as a reference to cell XL200. Type it with its quotes, "XL200", to look up the text.
The column index is checked while you type. It has to be a whole number of at least 1, and no wider than the range. Type 5 against Products!A2:D100 and the generator stops you with "Products!A2:D100 has 4 columns, so the column index can be at most 4. Excel would return #REF!." A defined name or table doesn't say how wide it is, so any index goes through there.
We checked the output in Excel for Mac against a three-row test table: =VLOOKUP(F1,$A$1:$D$3,3,FALSE) returned the right value from column 3, and the IFERROR version returned Not found for a code that wasn't there.
Why VLOOKUP breaks when you fill it down
Without $ signs, the table range travels with the formula. Put =VLOOKUP(A2,Products!A2:D100,3,FALSE) in row 2, fill it to row 50, and row 50 reads =VLOOKUP(A50,Products!A50:D148,3,FALSE). Any code listed in the top 48 rows of the price list is now outside the range and comes back #N/A. The codes further down still work. That mix of right answers and errors is why this one takes a while to spot.
$A$2:$D$100 pins the range. The lookup value needs the opposite: A2 has to stay relative so row 50 looks up A50. The generator therefore adds $ signs to the table array and never to a lookup cell, which goes in as you typed it.
VLOOKUP exact match, and the default that catches people
Leave off the fourth argument and VLOOKUP does an approximate match. =VLOOKUP(A2,Products!$A$2:$D$100,3) behaves as if it ended in TRUE. On a price list that isn't sorted smallest to largest, approximate match returns a nearby row with no error, so a wrong price looks exactly like a right one.
The generator always writes the fourth argument, and FALSE is the default. Exact match returns the row whose first column equals the lookup value, or #N/A.
Approximate match is right for bands. With thresholds 0, 50, 60 and 70 in column A and grades in column B, =VLOOKUP(64,$A$2:$B$5,2,TRUE) returns the grade next to 60, the largest threshold not above 64. Tax brackets and commission tiers work the same way. Pick TRUE in the generator and it warns you that the first column must be sorted smallest to largest.
Why VLOOKUP returns #N/A when the value is there
The generator never sees your workbook, so it can't tell you whether a code is in the table. When exact match returns #N/A for a code you can see on screen, the cause is almost always in the data:
- A trailing space.
ABC-104 with a space after it, pasted from a web export, doesn't equal ABC-104. =LEN(A2) shows the extra character, and TRIM in a helper column removes it. A space from a web page is often a non-breaking one, which TRIM leaves alone: =TRIM(SUBSTITUTE(A2,CHAR(160)," ")) handles both.
- A number stored as text. Code 1047 typed in one sheet won't match 1047 imported as text in the other. The text version usually sits left-aligned with a green triangle in the corner. VALUE converts it, and a free scan with the Workbook Audit lists the cells where numbers are stored as text.
- The code isn't in the first column. VLOOKUP searches only the leftmost column of the table array. If the codes are in column B, the range has to start at B.
- The range stops short. A price list that grew to row 140 isn't covered by
$A$2:$D$100. A whole-column range such as Products!$A:$D, or a table reference, grows with the data.
IFERROR VLOOKUP without hiding your mistakes
=IFERROR(VLOOKUP(A2,Products!$A$2:$D$100,3,FALSE),"Not found") shows Not found instead of #N/A for a missing code. The catch is that IFERROR swallows every error, not only #N/A. Delete a column from a four-column price list and a formula asking for column 4 now points past the edge of the table. The #REF! error that should tell you so shows as Not found on every row. Get the formula right without IFERROR, then tick the box. The generator shows that warning as soon as you tick the box.
If you only want to catch missing codes, change IFERROR to IFNA after pasting. The generator writes IFERROR only.
A blank fallback becomes "", which looks empty but is text. =E2*F2 on that cell returns #VALUE!. If the result column feeds arithmetic, type 0 as the fallback, and it goes in as a number.
Writing VLOOKUP in Excel without the generator
Excel has its own form for this. Formulas > Lookup & Reference > VLOOKUP opens the Function Arguments dialog (the Formula Builder on a Mac) with the same four boxes, and you can drag across the table on the sheet instead of typing its address. It won't add the $ signs, though. Click into the range in the formula bar and press F4 (Cmd+T on a Mac) to make it absolute. That route is better when you'd rather point at the table than type where it is.
On Excel 365 or Excel 2021, XLOOKUP is usually the better function. Exact match is its default, it can return a column to the left of the lookup column, and it takes the return column as a range, so inserting a column doesn't break it: =XLOOKUP(A2,Products!$A$2:$A$100,Products!$C$2:$C$100,"Not found"). VLOOKUP still earns its place in a workbook that has to open in Excel 2019 or older.
What the generator can't do
- It builds the formula without reading your data, so only Excel can tell you whether the lookup value is in the table.
- It separates arguments with commas. If your Excel uses semicolons, as it does in German, French and many other European setups, replace the commas between arguments with semicolons. A comma inside quoted text, as in
"Smith, John", stays.
- It writes VLOOKUP only: no HLOOKUP, XLOOKUP or INDEX and MATCH, and no wildcard option. For a partial match, type
="*"&A2&"*" as the lookup value: the leading = passes it through as written, and it works with exact match.
- It can't check the column index against a defined name or table reference, because it doesn't know their width.
- VLOOKUP itself returns only columns to the right of the lookup column, and only the first matching row. Its column index is a fixed number, so inserting a column inside the table shifts what
3 points at.
The VLOOKUP function page covers each argument in more depth, with worked examples.
Questions
What does FALSE mean in VLOOKUP?
FALSE asks VLOOKUP for an exact match, and it returns #N/A when the value isn't in the first column of the table. TRUE, or leaving the fourth argument off, asks for an approximate match instead. That needs the first column sorted smallest to largest, and on unsorted data it returns wrong rows without any error, so use FALSE unless you are looking up bands like grades or tax brackets.
Why is my VLOOKUP returning #N/A when the value is there?
Because the two values only look alike. A trailing space, or a code stored as text on one side and as a number on the other, is enough to make an exact match fail. Also check that the value sits in the first column of the table array, since that is the only column VLOOKUP searches.
Why does my VLOOKUP range change when I drag the formula down?
The table array is a relative reference, so Excel moves it down one row for every row you fill. Add $ signs, as in $A$2:$D$100, and the range stays put. The lookup cell should stay relative so each row looks up its own value.
How do I stop VLOOKUP showing #N/A?
Wrap it in IFERROR, for example =IFERROR(VLOOKUP(A2,$A$2:$D$100,3,FALSE),"Not found"). Be aware that IFERROR also hides real mistakes, such as a column index past the edge of the table. IFNA in the same position catches only #N/A and lets every other error show.
Can I use VLOOKUP across multiple sheets?
Yes. Put the sheet name and an exclamation mark in front of the range, as in Products!$A$2:$D$100, and wrap the sheet name in single quotes if it contains a space: 'Price list'!$A$2:$D$100. One VLOOKUP searches one range, so searching several sheets in turn means one VLOOKUP per sheet, each nested in the previous one's IFERROR.
Should I use VLOOKUP or XLOOKUP?
Use XLOOKUP when everyone who opens the file has Excel 365 or Excel 2021 or later. It defaults to exact match, can return a column to the left of the lookup column, and keeps working when someone inserts a column. Use VLOOKUP when the workbook has to open in Excel 2019 or older, where XLOOKUP shows #NAME?.
Can I use wildcards in VLOOKUP?
Yes, with exact match. An asterisk stands for any run of characters and a question mark for one character, so =VLOOKUP("*"&A2&"*",$A$2:$D$100,3,FALSE) returns the first row whose code contains the text in A2. The generator has no wildcard option, but typing ="*"&A2&"*" as its lookup value works, because anything starting with = goes in as written.