To match two columns with VLOOKUP, use the formula =VLOOKUP(lookup_value, table_array, col_index_num, FALSE) where the lookup_value is a cell from one column, and the table_array includes the other column plus the column you want to return. For example, to find a price in column C based on a product name in column A, with names in A2:A10 and prices in C2:C10, use =VLOOKUP(A2, $B$2:$C$10, 2, FALSE) if the names are actually in B. The key is that VLOOKUP only searches the first column of your chosen range, so if your two columns are not adjacent or the match column isn’t first, you must adjust the range or use a helper column.
Why VLOOKUP Only Looks at One Column
VLOOKUP is designed to search a single column—the leftmost column of the range you specify—and then return a value from a column to the right. It cannot directly compare two columns side-by-side and tell you if they match. If you want to check whether a value in column A exists in column B, VLOOKUP alone isn’t the right tool; you’d use COUNTIF or MATCH instead. But when you need to pull data from a second column based on a match in the first, VLOOKUP is the standard solution.
A common misconception is that VLOOKUP can match two columns at once (like matching both first and last name). It cannot. You must create a single lookup value by combining the two columns into one helper column, or use INDEX and MATCH with an array formula.
How to Match Two Columns with VLOOKUP (Step-by-Step)
Assume you have a list of employee IDs in column A and you want to pull the department from column D, but the ID column in the lookup table is column C. Here’s the exact process in Excel for Microsoft 365 on Windows:
- Click the cell where you want the result (e.g., B2).
- Type
=VLOOKUP(. - Click the cell with the lookup value (e.g., A2).
- Type a comma, then select the range that starts with the column containing the match (e.g., C:D). Press F4 to make it absolute (e.g.,
$C$2:$D$100). - Type a comma, then the column number to return (2 for the second column in the range).
- Type
, FALSE)and press Enter.
For Mac, the steps are identical; use Cmd+T instead of F4 to lock the range. In Excel for the web, F4 doesn’t work—type the dollar signs manually.
When Your Two Columns Aren’t Adjacent
VLOOKUP requires the lookup column to be the first column in the table_array. If your two columns are far apart, you have two options:
- Move the lookup column to the left of the data you want to return (cut and paste).
- Use a helper column that combines the two columns into one, then VLOOKUP on that.
For example, to match on both first name (column A) and last name (column B), insert a new column C and enter =A2&" "&B2 in C2, then copy down. Now use =VLOOKUP("John Smith", $C$2:$D$10, 2, FALSE) to return data from column D. This works because the helper column becomes the first column of your range.
Common VLOOKUP Errors and How to Fix Them
When matching two columns, you’ll likely hit one of these errors:
- #N/A – No exact match found. Check for extra spaces, non-printing characters, or number stored as text. Use
=TRIM(A2)to clean data, or=VALUE(A2)to convert text numbers. - #REF! – The col_index_num is greater than the number of columns in your range. If your range is C:D, col_index_num must be 1 or 2.
- #VALUE! – The col_index_num is less than 1, or the lookup_value is longer than 255 characters.
- Wrong results – If you use TRUE (approximate match) instead of FALSE, VLOOKUP may return a close but incorrect match. Always use FALSE for exact matching.
To handle errors gracefully, wrap the formula: =IFERROR(VLOOKUP(A2, $C$2:$D$10, 2, FALSE), "Not Found").
VLOOKUP vs. INDEX/MATCH vs. XLOOKUP for Two Columns
VLOOKUP is easy but limited. For matching two columns (like first and last name), consider these alternatives:
- INDEX/MATCH – Can look to the left, and with an array formula (Ctrl+Shift+Enter in older Excel) can match multiple criteria. Example:
=INDEX(D2:D10, MATCH(1, (A2:A10="John")*(B2:B10="Smith"), 0)). This works in Excel 365 without CSE. - XLOOKUP – Available in Excel 2021 and Microsoft 365. It can return a range, handle missing values, and search from the bottom. For two columns, you still need a helper column or use the
&concatenation inside:=XLOOKUP(A2&" "&B2, C2:C10&" "&D2:D10, E2:E10, "Not Found"). This is the cleanest modern solution.
For most users, XLOOKUP is the best choice if you have Excel 2021 or 365. If not, INDEX/MATCH is more flexible than VLOOKUP.
Using VLOOKUP to Compare Two Columns for Matches
If you actually want to know whether a value in column A appears in column B, VLOOKUP isn’t ideal. Instead, use COUNTIF:
With values in A2:A10 and B2:B10, enter in C2: =IF(COUNTIF($B$2:$B$10, A2)>0, "Match", "No Match"). This returns “Match” if the value in A2 exists anywhere in B. For a quick visual, use conditional formatting: select A2:A10, go to Home > Conditional Formatting > New Rule > Use a formula, and enter =COUNTIF($B$2:$B$10, A2)>0, then set a fill color.
If you need to return a value from a third column when two columns match (like both ID and date), you’ll need the helper column approach described earlier, or use INDEX/MATCH with multiple criteria.
Frequently Asked Questions
Can VLOOKUP match two columns in one formula?
No, VLOOKUP can only search one column. To match on two columns, create a helper column that concatenates the two values, then use VLOOKUP on that helper column. Alternatively, use XLOOKUP with concatenation inside the formula, or INDEX/MATCH with an array.
Why does VLOOKUP return #N/A even though I see the value?
Most often it’s due to invisible differences: extra spaces, non-printing characters, or numbers stored as text. Use TRIM and CLEAN functions to clean the data, or use the VALUE function to convert text numbers. Also, ensure you’re using FALSE for exact match.
How do I VLOOKUP from right to left?
VLOOKUP can’t look to the left. Use INDEX/MATCH instead: =INDEX(A2:A10, MATCH(D2, B2:B10, 0)) returns the value from column A where column B matches D2. XLOOKUP also handles this easily with =XLOOKUP(D2, B2:B10, A2:A10).
Is VLOOKUP case-sensitive?
No, VLOOKUP is not case-sensitive by default. If you need case-sensitive matching, use EXACT within an array formula, or use XLOOKUP with the match_mode argument set to 0 (exact) but it still isn’t case-sensitive. For case-sensitive, you’d need INDEX/MATCH with EXACT.
Can I use VLOOKUP to compare two columns and highlight differences?
Yes, but not directly. Use conditional formatting with a COUNTIF formula to highlight cells in column A that don’t exist in column B. Select column A, go to Home > Conditional Formatting > New Rule > Use a formula, and enter =COUNTIF($B$2:$B$10, A2)=0, then choose a format.
What’s the difference between VLOOKUP and HLOOKUP?
VLOOKUP searches vertically down the first column of a range; HLOOKUP searches horizontally across the first row. For matching two columns, VLOOKUP is the relevant one. HLOOKUP is for when your lookup values are in a row.
Related
- Count in Sheets: Google Sheets COUNT Function Guide
- How to Generate Random Numbers in C++
- JMP File: What It Is and How to Open One
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel Date Count Formula: Count Days and DatesIf your dates are real Excel date values in A2:A100, use =COUNT(A2:A100) to count the cells containing dates.…
- Excel Transpose Bottom to Top: Formulas and Fixes GuideTo transpose a vertical list from bottom to top into a horizontal row in Excel for Microsoft 365,…
- Excel Formula Line Break: How to Add One in a CellTo put a line break in an Excel formula, join the text with CHAR(10), then turn on Wrap…
- Excel XLOOKUP Function Examples for Everyday LookupsIn Excel for Microsoft 365, XLOOKUP finds a value in one range and returns the corresponding value from…
- Each of Four Functions? Meaning & Usage“Each of four functions” is not a standard phrase in mathematics or programming; it most commonly appears in…
- Excel Count Unique Values: 6 Ways to Ignore DuplicatesTo count unique values in Excel while ignoring duplicates, use =SUMPRODUCT(1/COUNTIF(range, range)) for a single column, or =COUNTA(UNIQUE(range))…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.