VLOOKUP lets you compare two columns of data by searching for a value from one column in another column and returning a result. The most common use is to check whether a value in column A exists in column B, and then return a “Match” or “No Match” label. You’ll need Excel 2010 or later (the steps work in Excel for Microsoft 365, Excel 2021, and earlier versions).
What You’ll Need
- Two columns of data in the same worksheet (e.g., Column A and Column B).
- A blank column where you want the comparison result (e.g., Column C).
- The data should be in a continuous range without blank rows in between.
Step-by-Step
- Open your Excel workbook and locate the two columns you want to compare. For this example, assume Column A has a list of names (A2:A10) and Column B has another list (B2:B10).
- Click on the first cell where you want the result to appear, say C2.
- Type the VLOOKUP formula for an exact match. The basic structure is:
=IF(ISNA(VLOOKUP(A2,$B$2:$B$10,1,FALSE)),"No Match","Match")This formula checks if the value in A2 is found anywhere in B2:B10. If VLOOKUP returns an error (because the value is not found), ISNA catches it and the IF returns “No Match”. If found, it returns “Match”.
- Press Enter. The result will appear in C2. For example, if A2 is “John” and “John” is in B2:B10, C2 shows “Match”. If not, it shows “No Match”.
- Copy the formula down to the rest of the cells in Column C. Click on C2, then drag the fill handle (the small square at the bottom-right corner of the cell) down to C10. Or double-click the fill handle to auto-fill if adjacent columns have data.
- Check the results. Each cell in Column C now tells you whether the corresponding value in Column A exists in Column B.
- Optional: Highlight matches. Use Conditional Formatting to color-code. Select A2:A10, go to Home > Conditional Formatting > New Rule > Use a formula. Enter
=ISNUMBER(MATCH(A2,$B$2:$B$10,0))and set a fill color for matches.
Common Mistakes
- Forgetting the FALSE argument: If you omit FALSE or use TRUE, VLOOKUP does an approximate match, which can return wrong results. Always use FALSE for exact comparison.
- Not using absolute references: When copying the formula, if you don’t lock the lookup range (e.g., using $B$2:$B$10), the range shifts and the formula breaks. Use dollar signs.
- Mismatched data types: If one column has numbers stored as text and the other as numbers, VLOOKUP won’t match them. Convert text to numbers or vice versa.
- Leading/trailing spaces: Extra spaces in cells cause “No Match” even when values look identical. Use TRIM to clean data.
- Blank cells: If a cell in Column A is blank, VLOOKUP returns an error. Handle blanks with IF(A2=””,””,…).
Tips
- Use MATCH instead of VLOOKUP for simple existence checks: The formula
=IF(ISNUMBER(MATCH(A2,$B$2:$B$10,0)),"Match","No Match")is faster and doesn’t require a return column. - Return a value from the second column: If you want to pull a related value (e.g., price) from Column B, use
=VLOOKUP(A2,$B$2:$C$10,2,FALSE)where Column B has the lookup value and Column C has the value to return. - Case-insensitive: VLOOKUP is not case-sensitive, so “John” and “john” are treated as equal. If you need case-sensitive matching, use EXACT with an array formula.
- Use IFERROR for cleaner output:
=IFERROR(VLOOKUP(A2,$B$2:$B$10,1,FALSE),"No Match")returns “No Match” directly, but it will also hide other errors like #N/A. For strict comparison, ISNA is better. - Sorting is not required: Unlike approximate match, exact match VLOOKUP works regardless of sort order.
Troubleshooting
- #N/A error: This means the value in A2 is not found in the lookup range. Double-check that the range is correct and that there are no typos or extra spaces.
- #VALUE! error: Often caused by mismatched data types (text vs number). Use the TEXT or VALUE functions to convert.
- #REF! error: The lookup range is invalid, usually because you deleted a column that was part of the range. Adjust the range in the formula.
- Results are all “Match” or all “No Match”: Check if your formula references the correct cell (e.g., A2 vs A1). Also ensure the lookup range is absolute.
- Formula returns “Match” for blanks: If A2 is blank, VLOOKUP may find a blank in Column B. Add a condition:
=IF(A2="","",IF(ISNA(VLOOKUP(A2,$B$2:$B$10,1,FALSE)),"No Match","Match")).
Frequently Asked Questions
- Can VLOOKUP compare two columns in different sheets? Yes. Use the sheet name in the range, e.g.,
=IF(ISNA(VLOOKUP(A2,Sheet2!$B$2:$B$10,1,FALSE)),"No Match","Match"). - What if I want to compare two columns and return a value from a third column? Use VLOOKUP with a return column index. For example, if Column A has IDs, Column B has names, and Column C has scores, use
=VLOOKUP(A2,$B$2:$C$10,2,FALSE)to get the score for the ID in A2. - Is there a way to compare two columns without a helper column? Yes, use Conditional Formatting to highlight matches directly. Select both columns, go to Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values, and choose a format.
- Why does VLOOKUP work but return the wrong value? If you use TRUE (approximate match) and your data is not sorted, it can return incorrect results. Always use FALSE for exact matches.
- Can I use VLOOKUP to compare more than two columns? VLOOKUP only compares one lookup value to one range. For multiple criteria, use INDEX/MATCH or XLOOKUP (Excel 2021/365).
- Does VLOOKUP ignore blank cells? No, it treats blanks as values. If a blank is in the lookup range, it can match a blank in the first column. Use the IF(A2=””,””,…) trick to avoid this.
Related
- Number to String Arduino: dtostrf & String() Guide
- Cell Counting and Viability: Methods Explained
- Split String SQL Server: Best Methods
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel Formula Has Text? How to Check & Use ItYes, an Excel formula can return text, and you can check whether a cell contains text using the…
- Balloon Payment Calculation: Formula & ExampleA balloon payment is calculated by taking the full loan amount, computing the monthly payments as if the…
- Excel Filter: How to Exclude Text From Your ResultsTo exclude rows containing particular text in Excel for Microsoft 365 on Windows, open the column’s filter arrow,…
- Excel Link to Named Range: Formulas and MethodsTo create a clickable link to a named range in Excel for Microsoft 365 on Windows, use the…
- Freeze Numbers in Excel: Keep Formula Results FixedTo freeze a number produced by a formula in Excel, copy the cell or range, then paste it…
- Excel IFS Default Value: Set a Reliable Fallback ResultExcel’s IFS function has no built-in default argument: if none of its tests is TRUE, it returns #N/A.…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.