VLOOKUP finds a value in the first column of a table and returns the value from a column you choose by number: =VLOOKUP(C2, Products!A2:D7, 4, FALSE) looks up the product code in C2 and returns the fourth column. XLOOKUP does the same job with separate lookup and return ranges, so it can look left and does not break when a column is inserted, but it needs Microsoft 365 or Excel 2021 onwards. INDEX MATCH works in every version and does everything XLOOKUP does, at the cost of a longer formula.
All three answer the same question: given this key, what is the matching value in that other table? This guide works through each one on the same data, then covers two-way lookups, lookups on two conditions, and the reasons a lookup returns #N/A.
Which lookup to use
The short answer: use XLOOKUP if everyone who opens the file has Microsoft 365 or Excel 2021 or later. Use INDEX MATCH if anyone might open it in Excel 2019 or older. Learn VLOOKUP regardless, because most existing workbooks in Indian offices are full of it and interviewers still ask about it.
| Feature | VLOOKUP | XLOOKUP | INDEX MATCH |
|---|---|---|---|
| Excel versions | All | Microsoft 365, Excel 2021, Excel 2024, Excel for the web | All |
| Google Sheets | Yes | Yes | Yes |
| Can return a column to the left of the key | No | Yes | Yes |
| Survives a column inserted in the table | No, the column number goes stale | Yes | Yes |
| Default match type | Approximate, unless you pass FALSE | Exact | Exact if you pass 0 to MATCH |
| Built-in message for a missing key | No, wrap it in IFNA | Yes, fourth argument | No, wrap it in IFNA |
| Returns several columns at once | No | Yes, the result spills | No |
The data used throughout
A pharmacy chain in Chennai keeps a product master on one sheet and store orders on another. The job is to bring each product’s MRP and category into the orders sheet.
The Products sheet, range A2:D7:
| A: product_id | B: product_name | C: category | D: mrp |
|---|---|---|---|
| P101 | Paracetamol 650 strip | Fever | 30 |
| P102 | Cetirizine 10 mg strip | Allergy | 18 |
| P103 | ORS sachet pack | Hydration | 21 |
| P104 | Vitamin D3 sachets | Supplements | 120 |
| P105 | Digital thermometer | Devices | 250 |
| P106 | Glucometer strips 50 | Diabetes | 950 |
The Orders sheet, with the product code in column C and quantity in column D:
| A: order_id | B: store | C: product_id | D: qty |
|---|---|---|---|
| C-1001 | Adyar | P104 | 3 |
| C-1002 | T Nagar | P101 | 10 |
| C-1003 | Velachery | P106 | 1 |
| C-1004 | Adyar | P107 | 2 |
| C-1005 | Anna Nagar | P102 | 5 |
P107 is deliberately missing from the master. Real data always has a row like this, and how each formula handles it matters.
VLOOKUP
VLOOKUP takes four arguments. The table it searches must have the key in its first column.
| Argument | What it means | In this example |
|---|---|---|
| lookup_value | The key you are looking for | C2, the product code |
| table_array | The table to search, key column first | Products!$A$2:$D$7 |
| col_index_num | Which column of that table to return, counting from 1 | 4, the mrp column |
| range_lookup | FALSE for an exact match, TRUE for approximate | FALSE |
Here is the formula in E2 of the Orders sheet, copied down, with a line value in F2 that multiplies quantity by MRP.
| order_id | product_id | E: =VLOOKUP(C2, Products!$A$2:$D$7, 4, FALSE) | F: =D2*E2 |
|---|---|---|---|
| C-1001 | P104 | 120 | 360 |
| C-1002 | P101 | 30 | 300 |
| C-1003 | P106 | 950 | 950 |
| C-1004 | P107 | #N/A | #N/A |
| C-1005 | P102 | 18 | 90 |
To return the category instead, change the 4 to a 3. The table range is locked with dollar signs so it stays put when the formula is copied down; without them, the range slides down a row with every copy, and by the second order P101 has already dropped out of it.
The #N/A for P107 is correct: the code is not in the master. Replace it with something readable using IFNA:
| Formula | Result for P107 |
|---|---|
| =IFNA(VLOOKUP(C5, Products!$A$2:$D$7, 4, FALSE), “Not in master”) | Not in master |
IFNA is better than IFERROR here, because IFERROR would also hide a typo in the formula itself.
Approximate match: looking up a slab
The fourth argument set to TRUE finds the largest value that is less than or equal to the key. That is wrong for product codes and exactly right for slabs. The chain gives a discount by order value, with the slab starts in Slabs!A2:A5 sorted smallest first and the rate in B2:B5.
| A: order value from | B: discount |
|---|---|
| 0 | 0% |
| 500 | 5% |
| 1000 | 8% |
| 2500 | 10% |
| Order value | =VLOOKUP(E2, Slabs!$A$2:$B$5, 2, TRUE) |
|---|---|
| 360 | 0% |
| 950 | 5% |
| 1000 | 8% |
| 2750 | 10% |
The slab column must be sorted ascending. On an unsorted list, approximate match does not error; it returns a confident wrong answer.
XLOOKUP
XLOOKUP asks for the column to search and the column to return as two separate ranges. There is no column number to count, so inserting a column into the master does not break anything.
| Argument | What it means | Required |
|---|---|---|
| lookup_value | The key you are looking for | Yes |
| lookup_array | The column to search | Yes |
| return_array | The column, or columns, to return | Yes |
| if_not_found | What to show when the key is missing | No |
| match_mode | 0 exact (the default), -1 exact or next smaller, 1 exact or next larger, 2 wildcard | No |
| search_mode | 1 first to last (the default), -1 last to first | No |
The same MRP lookup, with the missing-key message built in:
| product_id | =XLOOKUP(C2, Products!$A$2:$A$7, Products!$D$2:$D$7, “Not in master”) |
|---|---|
| P104 | 120 |
| P101 | 30 |
| P106 | 950 |
| P107 | Not in master |
| P102 | 18 |
Here is what XLOOKUP adds over VLOOKUP, on the same sheets.
| Job | Formula | Result |
|---|---|---|
| Look left: find the code for a product name | =XLOOKUP(“Digital thermometer”, Products!B2:B7, Products!A2:A7) | P105 |
| Return several columns at once | =XLOOKUP(“P104”, Products!A2:A7, Products!B2:D7) | Vitamin D3 sachets, Supplements, 120 spilled across three cells |
| Slab lookup with no sorting requirement | =XLOOKUP(950, Slabs!A2:A5, Slabs!B2:B5, , -1) | 5% |
In the slab version, the empty argument between the two commas skips if_not_found, and -1 asks for an exact match or the next smaller value. Unlike VLOOKUP’s TRUE, it does not need the slab table sorted.
Setting search_mode to -1 searches from the bottom up, which returns the latest entry for a key when a log has several. That is a common need with price-change logs.
INDEX MATCH
INDEX MATCH is two functions working together. MATCH finds the position of the key in a column. INDEX returns whatever sits at that position in another column.
| Part | What it does | Formula | Result |
|---|---|---|---|
| MATCH | Position of P104 in the code column | =MATCH(“P104”, Products!A2:A7, 0) | 4 |
| INDEX | Item 4 of the mrp column | =INDEX(Products!D2:D7, 4) | 120 |
| Together | Position found, then value returned | =INDEX(Products!D2:D7, MATCH(“P104”, Products!A2:A7, 0)) | 120 |
| Looking left | Code for a product name | =INDEX(Products!A2:A7, MATCH(“Digital thermometer”, Products!B2:B7, 0)) | P105 |
The 0 in MATCH means exact match, and forgetting it causes the same silent errors as leaving FALSE out of VLOOKUP. In Microsoft 365, XMATCH is a newer MATCH that defaults to exact.
INDEX MATCH has been the professional’s choice for years because it works in every version, looks in any direction, and survives inserted columns. If your office still runs Excel 2016 or 2019, it is the one to master.
Two-way lookup: row and column together
Sometimes you need the value where a row and a column cross, such as one store’s sales in one month. Here is a sales summary with stores in A2:A4 and months in B1:D1.
| A: Store | B: Sep | C: Oct | D: Nov |
|---|---|---|---|
| Adyar | 412000 | 438000 | 455000 |
| T Nagar | 521000 | 498000 | 530000 |
| Velachery | 365000 | 391000 | 402000 |
INDEX accepts a row position and a column position, so two MATCH functions give you both.
| Method | Formula | Result |
|---|---|---|
| INDEX with two MATCHes | =INDEX(B2:D4, MATCH(“T Nagar”, A2:A4, 0), MATCH(“Oct”, B1:D1, 0)) | 498000 |
| XLOOKUP inside XLOOKUP | =XLOOKUP(“T Nagar”, A2:A4, XLOOKUP(“Oct”, B1:D1, B2:D4)) | 498000 |
In practice, replace “T Nagar” and “Oct” with cell references fed by drop-downs, and you have a small interactive report.
Lookup on two conditions
Stock is held per product per store, so finding stock for P104 at T Nagar needs both conditions. The Stock sheet has product codes in A2:A5, stores in B2:B5 and units in C2:C5.
| A: product_id | B: store | C: units |
|---|---|---|
| P104 | Adyar | 14 |
| P104 | T Nagar | 6 |
| P101 | Adyar | 120 |
| P101 | T Nagar | 85 |
Multiplying two TRUE and FALSE tests gives 1 only on the row where both are true, so you look up 1.
| Method | Formula | Result |
|---|---|---|
| XLOOKUP | =XLOOKUP(1, (A2:A5=”P104″)*(B2:B5=”T Nagar”), C2:C5) | 6 |
| INDEX MATCH | =INDEX(C2:C5, MATCH(1, (A2:A5=”P104″)*(B2:B5=”T Nagar”), 0)) | 6 |
In Excel 2019 and older, the INDEX MATCH version must be entered with Ctrl+Shift+Enter. The other common approach is a helper column that joins the two keys, such as =A2&”-“&B2, then an ordinary lookup on that column.
Why a lookup returns #N/A or the wrong value
Most lookup problems are data problems, not formula problems. This is the checklist to run before rewriting anything.
| What you see | Usual cause | Fix |
|---|---|---|
| #N/A for a key you can see in the master | A trailing space, as in “P104 “ | Clean the key column with TRIM |
| #N/A on numeric codes such as 101 | One side is a number stored as text | Convert with VALUE, or both sides with TEXT |
| A plausible but wrong value | VLOOKUP’s last argument left out, so it did an approximate match | Add FALSE |
| Correct in the first rows, #N/A further down | Table range not locked, so it slid as the formula was copied | Lock it with F4 to get dollar signs |
| Wrong column after someone edited the master | A column was inserted and the col_index_num is now stale | Switch to XLOOKUP or INDEX MATCH |
| Only the first of several matching rows comes back | Lookups return the first match by design | Remove duplicates, or use XLOOKUP’s search_mode of -1 for the last |
Locking ranges is explained step by step in our guide to absolute and relative cell referencing.
Lookups and SQL joins
A lookup is Excel’s version of a join. VLOOKUP across a whole orders sheet does the same job as a LEFT JOIN from orders to products in SQL, keeping every order and showing nothing where the product is missing. If you already understand lookups, our lesson on SQL joins will feel familiar, and it is where the same work moves once a sheet gets too large for Excel.
Frequently asked questions
What is the VLOOKUP formula in Excel?
The syntax is =VLOOKUP(lookup_value, table_array, col_index_num, FALSE). For example, =VLOOKUP(C2, Products!A2:D7, 4, FALSE) finds the code in C2 in the first column of the Products table and returns the value from its fourth column. Always use FALSE as the last argument unless you are looking up a slab.
What is the difference between VLOOKUP and XLOOKUP?
VLOOKUP searches the first column of a table and returns a column you specify by number, so it cannot look left and breaks when columns are inserted. XLOOKUP takes the search column and the return column separately, defaults to exact match and has a built-in message for missing keys. XLOOKUP needs Microsoft 365 or Excel 2021 onwards, while VLOOKUP works in every version.
Is INDEX MATCH better than VLOOKUP?
For most work, yes. INDEX MATCH can return a column to the left of the key, does not depend on counting columns, and works in every Excel version. VLOOKUP is shorter to write, which is why it remains common, but INDEX MATCH or XLOOKUP is the safer choice in a workbook other people will edit.
Why is my VLOOKUP returning #N/A?
Either the key genuinely is not in the table, or the two values look the same but are not. The usual culprits are trailing spaces, a number stored as text on one side, or a table range that shifted because it was not locked with dollar signs. Clean the keys with TRIM and check both sides are the same type.
Is XLOOKUP available in Excel 2019 or Excel 2016?
No. XLOOKUP is available in Microsoft 365, Excel 2021, Excel 2024 and Excel for the web, but not in Excel 2019 or older. A file that uses it shows a #NAME? error when opened in those versions. Use INDEX MATCH if your file will travel to older versions.
Does Google Sheets have XLOOKUP?
Yes. Google Sheets supports XLOOKUP with the same arguments as Excel, alongside VLOOKUP and INDEX MATCH. Formulas written in one generally work in the other.
Lookups are where Excel interviews start
Lookups are the question most likely to come up in an Excel interview, usually followed by “what if the key is missing?” For where they sit among the other formulas analysts use, see our guide to Excel for data analysis.
SkilloVilla’s Excel: Beginner to Advanced course has a module on lookup functions, alongside named ranges, conditional, text and date functions, data cleaning, pivot tables and interactive dashboards, taught in live classes by working professionals. If you want Excel inside a full analyst programme with SQL, Python and placement support, see the Data Analytics with Python track.