The most advanced VLOOKUP techniques combine it with IFERROR, MATCH, and array formulas to handle multiple criteria, dynamic columns, and errors—here’s the exact cheat sheet. Below are the formulas and setups you need for Excel 365, 2021, and earlier versions, with clear examples and the logic behind each.
Why VLOOKUP Still Matters (and Its Limits)
VLOOKUP is the most-used lookup function in Excel because it’s simple: it searches for a value in the first column of a table and returns a value from a column to the right. But it has real constraints—it only looks left-to-right, it returns the first match only, and it breaks if you insert a column in the table array. Advanced users pair it with other functions to work around these limits, or switch to XLOOKUP when available. Knowing the workarounds is still valuable because many shared workbooks and legacy templates rely on VLOOKUP.
Core Advanced VLOOKUP Formula Patterns
Assume your data is in A2:D100, with headers in row 1: Product ID, Product Name, Category, Price. You want to look up a product ID in cell G2 and return its price.
- Basic exact match:
=VLOOKUP(G2,A2:D100,4,FALSE)— returns the price from column 4. FALSE forces an exact match; TRUE (or omitted) uses approximate match, which is rarely what you want. - Dynamic column index:
=VLOOKUP(G2,A2:D100,MATCH("Price",A1:D1,0),FALSE)— the MATCH function finds the column number for “Price” so you don’t hard-code 4. This survives column insertions. - Error handling:
=IFERROR(VLOOKUP(G2,A2:D100,4,FALSE),"Not Found")— returns a friendly message instead of #N/A. - Multiple criteria (concatenation trick): Add a helper column E with
=A2&"|"&B2(drag down), then use=VLOOKUP(G2&"|"&H2,E2:D100,4,FALSE)— but note the table array must start at E2, and the return column is now 4 (E=1, F=2, G=3, H=4). This works in all Excel versions. - Case-sensitive lookup:
=VLOOKUP(TRUE,CHOOSE({1,2},EXACT(A2:A100,G2),D2:D100),2,FALSE)— this is an array formula (press Ctrl+Shift+Enter in older Excel; in 365 it just works). EXACT compares case, CHOOSE builds a virtual two-column array.
How to Build a Dynamic Column Index with MATCH
The static column number (like 4) is the most common reason VLOOKUP fails when someone adds a column. Instead, use MATCH to locate the header dynamically. With headers in A1:D1 and the lookup value in G2:
- Enter the header name you want to return in a cell, say I1 (e.g., “Price”).
- Use
=VLOOKUP(G2,A2:D100,MATCH(I1,A1:D1,0),FALSE). - MATCH returns the position of “Price” among the headers. If you rename the header, the formula updates automatically.
This pattern works in Excel 2010 and later. For Excel 365, XLOOKUP does this natively with =XLOOKUP(G2,A2:A100,D2:D100)—no column index needed.
VLOOKUP vs. XLOOKUP vs. INDEX-MATCH
When to use which depends on your Excel version and the task:
- VLOOKUP — works in all versions, but only rightward lookups, first match only, and it can be slow on large datasets (over ~100k rows).
- INDEX-MATCH —
=INDEX(D2:D100,MATCH(G2,A2:A100,0))— allows leftward lookups and is faster than VLOOKUP on large data. Works in all versions. - XLOOKUP —
=XLOOKUP(G2,A2:A100,D2:D100)— needs Excel 2021 or 365. It handles leftward lookups, returns multiple matches, has built-in error handling (e.g.,=XLOOKUP(G2,A2:A100,D2:D100,"Not Found")), and is the modern replacement.
If you’re building a new spreadsheet in 365, use XLOOKUP. If you must share with older Excel, use INDEX-MATCH or VLOOKUP with MATCH. The cheat sheet above still applies to legacy workbooks.
Common VLOOKUP Errors and How to Fix Them
- #N/A — No exact match. Check for extra spaces (use TRIM), numbers stored as text (use VALUE), or non-printable characters (use CLEAN). Also confirm the lookup column is the first column of the table array.
- #REF! — The column index number is greater than the number of columns in the table array. If your table is A2:D100, index 5 fails.
- #VALUE! — The column index is less than 1, or the lookup value is longer than 255 characters (rare). Use
=VLOOKUP(LEFT(G2,255)&"*",...)as a workaround. - Wrong results with TRUE — Approximate match requires the first column sorted ascending. If you use TRUE without sorting, you get unpredictable results. Always use FALSE unless you’re doing a range lookup (like tax brackets).
- Leading/trailing spaces — Use
=TRIM(G2)for the lookup value, or clean the source data with=TRIM(A2)in a helper column.
Advanced Array and Wildcard VLOOKUP Tricks
Wildcards work with exact match: =VLOOKUP("*"&G2&"*",A2:D100,4,FALSE) finds the first product whose name contains the text in G2. The asterisk matches any sequence, and the question mark matches a single character. To escape a literal asterisk or question mark, use a tilde ~ before it.
For returning multiple matches (e.g., all orders for a customer), VLOOKUP alone can’t do it. Use an array formula with SMALL and IF: {=IFERROR(INDEX(B2:B100,SMALL(IF(A2:A100=G2,ROW(A2:A100)-1),ROW(1:1))),"")} — enter with Ctrl+Shift+Enter in older Excel; in 365, it just works. Drag down to list all matches. This is a classic advanced pattern.
Performance and File Size Considerations
VLOOKUP is computationally expensive. On a 100,000-row table, each formula scans the first column until it finds a match. To speed up:
- Sort the first column ascending and use
TRUEfor approximate match—this uses binary search and is much faster, but only if your data is truly sorted and you accept the nearest match. - Limit the table array to the exact range (e.g., A2:D100 instead of A:D) to reduce the scan area.
- Use a helper column with a concatenated key and exact match—Excel can sometimes optimize this better.
- Convert the range to an Excel Table (Ctrl+T) and use structured references like
=VLOOKUP(G2,Table1,4,FALSE)—this keeps the range dynamic and improves readability. - For massive datasets, consider Power Query or a pivot table instead of thousands of VLOOKUP formulas.
Frequently Asked Questions
Can VLOOKUP return multiple columns at once? Not directly. In Excel 365, you can use =VLOOKUP(G2,A2:D100,{2,3,4},FALSE) as a dynamic array formula to spill three results. In older Excel, you’d need three separate formulas or an array formula with TRANSPOSE.
Why does VLOOKUP return #N/A when the value clearly exists? Most often it’s a formatting mismatch—numbers stored as text, or invisible spaces. Use =TRIM(A2) on the source and =VALUE(G2) on the lookup value. Also check that the lookup column is the first column in the table array.
Is VLOOKUP case-sensitive? No, by default it is not. To make it case-sensitive, use the array formula with EXACT as shown above, or switch to XLOOKUP with the match mode argument (but XLOOKUP also isn’t case-sensitive by default—you’d need to combine with EXACT).
What is the difference between VLOOKUP and HLOOKUP? VLOOKUP searches vertically (down the first column) and returns a value to the right. HLOOKUP searches horizontally (across the first row) and returns a value below. HLOOKUP is rarely used because most data is vertical.
Can I use VLOOKUP to look up from right to left? No, VLOOKUP only looks rightward. Use INDEX-MATCH or XLOOKUP for leftward lookups. For example, =INDEX(A2:A100,MATCH(G2,D2:D100,0)) returns the product ID from column A where the price in column D matches G2.
Does VLOOKUP work with merged cells? It can, but it’s unreliable. Merged cells only hold a value in the top-left cell; the other cells are empty. It’s better to unmerge and fill down the values, or use a helper column.
Related
- Python Enum Multiple Values: How to Use Them
- Enums in Python 3: A Complete Guide
- SQL COUNT DISTINCT Multiple Columns: How It Works
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel Text Unique Values: Extract, Count, and CompareYes. In Excel for Microsoft 365, use UNIQUE to return a list of distinct text values from a…
- String Function: Meaning, Examples, and Excel UsesA string function is a function that works with text made up of characters: it might count, extract,…
- Excel UPPER Function: How to Make Text All CapsExcel’s uppercase text function is UPPER. In Microsoft Excel for Microsoft 365, enter =UPPER(A2) to convert the text…
- Excel Not Allowing Me to Drag a Formula? Try These FixesIf Excel will not let you drag a formula, turn on File > Options > Advanced, then under…
- Excel Formula for Savings Growth: FV & MoreThe core Excel formula for savings growth is =FV(rate, nper, pmt, [pv], [type]), where you plug in the…
- Daily Attendance Sheet in Excel With FormulasTo make a daily attendance sheet in Excel, put employee or student names in column A, dates across…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.