Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Compare Two Sets of Excel Data

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, you can compare two sets of data in Excel to find matches, differences, or unique values between them. The method depends on whether you want to check for exact matches, partial matches (like containing a text string), or check if a value in one list exists in another. The process is built directly into Excel and does not require any add-ins or external software. The most common approach is using the VLOOKUP function, the MATCH function, or the newer XLOOKUP function, which provides more reliable results and easier syntax. For comparing lists without formulas, you can use the Conditional Formatting feature to highlight rows that are identical or different instantly.

What You'll Need

  • A computer with Microsoft Excel installed (2016 or later is recommended for XLOOKUP).
  • Two columns of data that you want to compare. These can be names, product codes, dates, or any other text or number values.
  • A basic understanding of cell references (like A1, B2) is helpful.

Step-by-Step

  1. Organize your data. Ensure your data is in two separate columns. For example, put the first list of data in column A and the second list in column B. It is best practice to have headers in row 1 (e.g., "List 1" in A1 and "List 2" in B1) to keep track of what each column represents.
  2. Choose your comparison method. The method you use depends on the specific outcome you need. The three most common scenarios are: finding all items that exist in both lists, finding items that are only in one list, and finding the specific row where two values match. The following steps cover the most versatile method using the XLOOKUP function.
  3. Identify the lookup value. This is the value from your first list that you want to find in the second list. For example, if you have a list of sales in column A and you want to check if those sales are in a list of approved customers in column B, you would use the value in cell A2 as your lookup value.
  4. Identify the lookup array. This is the entire column of data from the second list that you are searching through. Using the same example, this would be the entire column B (B:B or B2:B1000), assuming your second list starts in row 2 and has data down to row 1000.
  5. Identify the return array. This is the column from the second list that you want to retrieve a value from. If you just want to know if the item exists, you can return a simple message like "Yes" or "No". If you want to retrieve more information associated with the match, you would specify that column. For a simple existence check, use a column of empty cells (like C:C) or a column containing a dummy value like 1.
  6. Enter the XLOOKUP formula. In a new column (e.g., column C), type the following formula structure into the first cell (C2). Replace the placeholders with your actual cell references.
    =XLOOKUP(A2, B:B, C:C, "Not Found")
    Here is a breakdown of the formula parts:
    • A2: The value you are looking for (from your first list).
    • B:B: The column you are searching in (your second list).
    • C:C: The column you are returning a value from (can be a dummy column).
    • "Not Found": The value to return if the lookup value is not found in the lookup array. This is a very important part of the formula.
  7. Drag the formula down. Click on the small square handle in the bottom-right corner of the cell with your formula (C2) and drag it down to apply the formula to all the rows in your first list. Excel will automatically update the cell references for each row.
  8. Interpret the results. After copying the formula, you will see one of two results in column C:
    • If the result is "Not Found", it means the value from column A was not found anywhere in column B. This indicates a difference or a unique value.
    • If the result is any other value (like a number or the dummy value you specified), it means the value from column A was found in column B. This indicates a match.
  9. Filter for matches or differences. You can now use the built-in filtering feature to quickly isolate the data you need. Click on the header of column C ("Not Found") and use the filter arrows to sort the data. You can filter for "Not Found" to see only the unique values from your first list, or filter for everything except "Not Found" to see only the matches.

Common Mistakes

One of the most common mistakes when comparing data is using the wrong range for the lookup array. A frequent error is referencing only the header row (e.g., B1) instead of the entire column (e.g., B:B). This will result in the formula only finding a match if the value is in the very first row of the second list. Always reference the entire column to ensure you are searching through all the data. Another mistake is not accounting for the fact that Excel is case-sensitive when comparing text strings. If you have "Apple" and "apple" in your lists, XLOOKUP will not consider them a match. You can use the EXACT function if you need a case-insensitive comparison, though this is less common for simple list comparisons.

Tips

When comparing large datasets, using full column references like A:A is fast and convenient. However, if your lists are very short (a few dozen rows), it is often more precise to use specific ranges like A2:A50 to avoid accidentally including empty cells at the bottom of your data. If you are using an older version of Excel that does not have XLOOKUP, you can use the VLOOKUP function as a fallback. The syntax for VLOOKUP is slightly different and requires you to specify the column index number of the return array rather than the array itself. For example, =VLOOKUP(A2, B:B, 1, FALSE) would return the value from the first column of the lookup range (B:B) if a match is found, or an error if not. Remember that the lookup column in VLOOKUP must be the first column in the range you specify.

Troubleshooting

If the formula returns #N/A for every cell, the most common cause is that the data in the two lists is not formatted the same. For example, one list might have numbers stored as text and the other as actual numbers. Check for hidden spaces by using the TRIM function on your data, or use the VALUE function to convert text to numbers. If you are comparing text and are certain the data matches, check for special characters or invisible Unicode characters that might not be visible on the screen. Another issue is that the lookup array might not be sorted, but this is not a problem for XLOOKUP. For VLOOKUP, the lookup column must be the first column in the range, so ensure you have ordered your columns correctly if you are using that function.

Frequently Asked Questions

Can I compare two lists and highlight the differences in color?

Yes, you can use Conditional Formatting. Select your data, go to the Home tab, click "Conditional Formatting," and choose "New Rule." Select "Use a formula to determine which cells to format" and enter a formula like =A1<>B1. This will highlight any cell in column A that is different from the corresponding cell in column B.

Why does XLOOKUP return an #VALUE! error?

An #VALUE! error in XLOOKUP usually means that the data type in the lookup value (e.g., a number) does not match the data type in the lookup array (e.g., text). Ensure that the numbers in both columns are formatted as numbers and not as text.

How do I find values that appear in one list but not the other?

The method described above with XLOOKUP is the most direct way. If the result is "Not Found", it means that value is unique to the first list. You can filter the column of results for "Not Found" to see only these unique values.

Is there a way to compare two columns without using a formula?

Yes, you can use the "Remove Duplicates" feature. Select your first list, go to the Data tab, and click "Remove Duplicates." This will give you a list of only the unique values from that list. You can then compare this resulting list to your second list to see which items are missing. This is a quick and easy way to check for differences.

What is the difference between VLOOKUP and XLOOKUP?

XLOOKUP is a newer function that is easier to use and more powerful than VLOOKUP. It does not require you to specify the column index number, and it is guaranteed to return a value (you can specify what to return if no match is found). VLOOKUP is more prone to errors if the columns are ordered differently than expected.