Comparing two Excel sheets is done by using the "Conditional Formatting" rule to highlight cells that are different, or by using the "IF" function to flag discrepancies between values. You can also use the "Compare Files" tool in the "Info" tab to see a summary of what has changed. This guide covers the most common methods for comparing data, from simple visual checks to formula-based analysis.

What You'll Need

  • Two Excel files (or two sheets within the same workbook) containing the data you wish to compare.
  • A computer running Microsoft Excel (Windows or macOS). Excel for the Web (in a browser) has limited conditional formatting capabilities for this specific task, so desktop versions are recommended for the full experience.
  • Basic knowledge of Excel cell references (using the $ symbol for absolute references is helpful for formulas).

Step-by-Step

  1. Prepare your data. Ensure both sheets are sorted in the same order. If one list is in alphabetical order and the other is not, the comparison will be inaccurate even if the data is identical. It is best to have the columns in the same order and the rows aligned by a common identifier (like a SKU or ID number).
  2. Open both files. Launch Excel and open the first workbook containing your primary data. Open the second workbook containing the data you want to compare against it.
  3. Select the data range. Go to the first sheet. Click and drag to highlight the entire range of cells you want to compare. Do not include headers in this selection unless you want to see them highlighted if they differ.
  4. Open Conditional Formatting. On the Home tab of the ribbon, look for the Styles group. Click on "Conditional Formatting" and select "New Rule..." from the dropdown menu.
  5. Select the rule type. In the "New Formatting Rule" dialog box, select "Use a formula to determine which cells to format" from the list of rule types at the top.
  6. Enter the comparison formula. In the box labeled "Format values where this formula is true:", enter a formula that compares the first cell in your selection to the corresponding cell in the second sheet. Assuming your first cell is A2, click over to the second sheet, click on cell A2 there, and enter a formula to check for inequality. For example: =A2<>Sheet2!A2. The operator <> means "not equal to." If you want to check for a difference in values, this is the correct formula. If you want to check if a cell is empty in one sheet but not the other, you might use =OR(A2="",Sheet2!A2<>").
  7. Set the formatting style. Click the "Format..." button. Go to the Fill tab and choose a background color (like yellow or red) that will make the differences obvious. You can also use the Font tab to make the text bold or change the color to black. Click OK to close the Format Cells dialog.
  8. Apply the rule. Click OK again on the "New Formatting Rule" dialog box. You will now see the cells that are different highlighted in your chosen color.
  9. Review the results. Scan the highlighted cells. If the data is identical, no cells should be highlighted. If there are discrepancies, the highlighting will show you exactly where they are. You can then manually check the highlighted cells to determine if the data in the second sheet is correct or if it represents an error.

Common Mistakes

A common mistake is failing to account for hidden characters or formatting differences. For example, a cell might appear to contain "100" in both sheets, but one might actually contain "100" followed by a non-breaking space. The visual comparison will miss this, but the inequality formula will catch it. Another frequent error is selecting the wrong range of cells; if you select more or less data in the first sheet than the second, the comparison will be misaligned.

Tips

When using formulas to compare data, it is often helpful to add a helper column that displays the result of the comparison. For instance, in a column next to your data, you could use the formula =IF(A2=Sheet2!A2,"Match","Diff"). This text output is much easier to read and filter than a sheet of colored cells, especially if you have hundreds of rows of data. Always ensure that the cell references are correct; for example, if you are comparing the first row, use A2 vs Sheet2!A2. If you are comparing the second row, use A3 vs Sheet2!A3.

Troubleshooting

If the conditional highlighting is not working as expected, first double-check your formula. Make sure you are referencing the correct cells and that you are using the correct inequality operator (<>). If the formula looks correct but the highlighting is still wrong, try clearing the formatting on the range and re-applying it. Sometimes a cached rule can behave unexpectedly. If you are comparing text values, remember that Excel is case-sensitive by default. "Apple" and "apple" will be considered different values. If you want to ignore case, you can use the EXACT function in your formula, like this: =NOT(EXACT(A2,Sheet2!A2)).

Frequently Asked Questions

Can I compare two Excel sheets without using formulas?

Yes, you can use the "Compare Files" feature in Excel. Open the main file, go to the "File" tab, select "Info," and look for the "Compare" button. This will open a specialized tool that shows you a summary of added, deleted, and modified files and cells. It is a good option for a quick overview, but it doesn't allow you to highlight discrepancies directly in your original spreadsheet.

Why does my comparison show no differences even when I know there are some?

This often happens due to invisible characters, like spaces, at the end of a cell. For example, one sheet might have "Product A" and the other might have "Product A ". The conditional formatting rule =A2<>Sheet2!A2 will detect this as a difference, but if you are reading the cells visually, it will look the same. You can check for this by looking at the formula bar to see the full content of the cell.

How do I compare columns of different lengths?

Conditional formatting works best when the ranges are the same size. If one column is longer than the other, the formula will return a #REF! error for the extra cells in the shorter column. To handle this, you can use the IFERROR function in your formula to suppress the error. For example: =IFERROR(A2<>Sheet2!A2,TRUE). This will highlight the cells in the shorter column as different.

Is there a way to compare data across multiple columns at once?

Yes, you can extend your formula to cover multiple columns. For example, if you are comparing two rows side-by-side, you could use a formula like =OR(A2<>Sheet2!A2, B2<>Sheet2!B2). This will highlight the cell if any of the corresponding columns in the two rows contain different values.

Can I use this method to find duplicate rows between two sheets?

Yes, you can adapt the formula to check for duplicates. To highlight a cell in Sheet1 if the value already exists somewhere in Sheet2, you could use a formula like =COUNTIF(Sheet2!A:A,A2)>0. This will count how many times the value in A2 appears in column A of Sheet2 and highlight the cell if the count is greater than zero.