Comparing data in Excel is most effectively achieved by using a logical formula (like =A2=B2), Conditional Formatting to highlight differences, or the VLOOKUP/XLOOKUP functions to find missing entries across lists. These methods allow you to identify duplicates, find discrepancies between two versions of a file, or spot missing records in a master list.
What You'll Need
- Microsoft Excel (Desktop version recommended for full feature access).
- Two sets of data to compare (either on the same worksheet or in two different worksheets/workbooks).
- Data that is cleaned (no leading or trailing spaces) for the most accurate results.
Step-by-Step
Depending on your goal—whether you want to see if two cells are identical or find which items from List A are missing in List B—choose one of the following methods. Note that menu labels may differ slightly based on your version of Excel or region.
Method 1: The Simple Logical Test (Best for Side-by-Side Comparison)
Use this when you have two columns of data and want to know if the values in the same row are exactly the same.
- Place your two lists in adjacent columns (e.g., Column A and Column B).
- Click in the first empty cell of the next column (e.g., Cell C2).
- Type the formula
=A2=B2and press Enter. - Excel will return TRUE if the cells are identical and FALSE if they are different.
- Hover over the bottom-right corner of cell C2 until the cursor becomes a small black cross, then double-click or drag it down to apply the formula to the rest of the list.
Method 2: Conditional Formatting (Best for Visual Highlighting)
Use this to instantly color-code cells that are duplicates or unique across two ranges.
- Highlight both columns of data you wish to compare.
- Go to the Home tab on the ribbon.
- Click Conditional Formatting > Highlight Cells Rules > Duplicate Values...
- In the dialog box, select Duplicate from the first dropdown to highlight matches, or select Unique to highlight the differences.
- Choose your preferred highlight color from the second dropdown and click OK.
Method 3: Using VLOOKUP (Best for Finding Missing Data)
Use this when you have two lists of different lengths and want to see if an item from List A exists anywhere in List B.
- Assume List A is in Column A and List B is in Column E.
- In cell B2 (next to the first item in List A), enter:
=VLOOKUP(A2, E:E, 1, FALSE). - Press Enter.
- If the value exists in List B, Excel will display the value. If it does not exist, Excel will return a #N/A error.
- To make this cleaner, wrap it in an IFERROR formula:
=IFERROR(VLOOKUP(A2, E:E, 1, FALSE), "Missing"). This will display the word "Missing" instead of the error code.
Method 4: Using XLOOKUP (The Modern Alternative)
If you are using a newer version of Excel (Microsoft 365), XLOOKUP is more flexible than VLOOKUP.
- In the cell next to your first data point, enter:
=XLOOKUP(A2, E:E, E:E, "Not Found"). - The first argument (A2) is what you are looking for; the second (E:E) is where to look; the third (E:E) is what to return; and the fourth ("Not Found") is what to show if no match is found.
- Drag the formula down to complete the comparison.
Common Mistakes
- Ignoring Hidden Spaces: A cell containing "Apple " (with a space) is not the same as "Apple". This causes formulas to return FALSE or #N/A even when the words look identical.
- Case Sensitivity: Standard Excel formulas like VLOOKUP and the = sign are not case-sensitive. "APPLE" and "apple" are treated as the same.
- Comparing Different Data Types: Comparing a number stored as text to a number stored as a value will result in a mismatch, even if the digits are the same.
- Incorrect Range Locking: When using VLOOKUP with a specific range (e.g., E2:E100) instead of a whole column (E:E), forgetting to use absolute references (e.g., $E$2:$E$100) will cause the range to shift as you drag the formula down.
Tips
- Use TRIM: To fix the "hidden space" issue, create a helper column using
=TRIM(A2)to remove all leading and trailing spaces before comparing. - Filter by Color: After using Conditional Formatting, you can go to the Data tab, click Filter, and then use the filter dropdown on the column header to "Filter by Color" to see only the discrepancies.
- Convert to Tables: Press Ctrl+T to turn your data into a Table. This makes formulas automatically expand when you add new rows to your lists.
Troubleshooting
If your comparison is not returning the expected results, try these steps in order:
- Check for formatting mismatches: Select your columns, go to the Home tab, and ensure both are set to the same format (e.g., both "General" or both "Text").
- Clear existing formatting: If Conditional Formatting is acting strangely, go to Conditional Formatting > Clear Rules > Clear Rules from Entire Sheet and start over.
- Verify Formula References: Double-check that your VLOOKUP or XLOOKUP is pointing to the correct columns. A common error is accidentally selecting the wrong column as the lookup array.
- Recalculate the sheet: If formulas aren't updating, press F9 to force a recalculation of all formulas in the workbook.
Frequently Asked Questions
How do I compare two columns and highlight the differences?
The fastest way is to select both columns, go to Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values, and change the dropdown from "Duplicate" to "Unique".
Can I compare data across two different Excel files?
Yes. When writing your formula (like VLOOKUP), instead of selecting a range in the current sheet, click over to the other open workbook and select the range there. Excel will automatically add the file name to the formula.
Is there a way to compare data that is case-sensitive?
Yes. Use the EXACT function. Instead of =A2=B2, use =EXACT(A2, B2). This will return TRUE only if the capitalization is identical.
How do I find values that are in List A but NOT in List B?
Use the VLOOKUP or XLOOKUP method described above. Any cell that returns #N/A (or your custom "Missing" text) represents a value that exists in List A but is absent from List B.
Why does Excel say two cells are different when they look the same?
This is usually caused by invisible characters, such as trailing spaces or non-breaking spaces from web imports. Use the TRIM function to clean the data first.