How to compare two columns in Excel

Row by row with one formula, highlighted in two clicks, and across two sheets when the rows are not in the same order.

Two price columns compared row by row; two rows marked Different
The example from this guide: January and February prices, two of them changed.

To compare two columns in Excel row by row, put this formula in an empty column next to them and fill it down:

=IF(B2=C2, "Same", "Different")

Every row now says whether the value in column B matches the value in column C. The example in this guide is a price list: SKU in column A, the January price in B and the February price in C. Two prices changed.

Spreadsheet with SKU, January and February prices; the formula in column D marks rows 3 and 6 as Different
The formula in D2, filled down. A-101 and A-104 have new prices.

This works when the two columns describe the same thing on the same row. If you want to know which values of one column appear anywhere in the other (two lists of emails, for example), that is a different question: see how to compare two lists in Excel.

1. Same row, same value: one formula

=B2=C2 on its own returns TRUE or FALSE. Wrapping it in IF gives words that are easier to filter on. A few useful variants:

  • Only mark the differences: =IF(B2<>C2, "Different", ""). Then filter column D on “Different”.
  • Letter case matters: = treats acme and ACME as equal. =IF(EXACT(B2, C2), "Same", "Different") does not.
  • Numbers that may differ by rounding: =IF(ABS(B2-C2)<0.005, "Same", "Different") treats 12.50 and 12.499 as the same price.
  • How much it changed: =C2-B2 for the difference, or =C2/B2-1 formatted as a percentage.

Count the result with =COUNTIF(D2:D7, "Different") so you know how many rows to check before you scroll.

2. Highlight the cells that differ

If you would rather see the differences than add a column, colour them with conditional formatting:

  1. Select the cells to colour, here B2:C7.
  2. Home → Conditional Formatting → New Rule → Use a formula to determine which cells to format.
  3. Enter =$B2<>$C2, click Format, pick a fill and press OK.
Columns B and C with rows 3 and 6 filled in amber by a conditional formatting rule
The rule colours both cells of every row where the prices differ.

The $ before the column letters keeps the rule on columns B and C, and the missing $ before the row number lets it move down row by row. The colour updates when a value changes.

A one-off check without a rule: select B2:C7 starting in B2 and press Ctrl+\, or go to Home → Find & Select → Go To Special → Row differences. Excel selects the cells in each row that differ from the cell in column B. Fill them with a colour while they are selected.

After Ctrl+backslash only C3 and C6 are selected
Row differences compares each row with the column of the cell you started in.

3. Two sheets, rows in a different order

Row by row stops working as soon as the rows are not in the same order. That is usual for two exports: the February sheet below has the same products sorted differently, one new product (A-106) and one that is gone (A-105).

February sheet with SKUs in a different order, including A-106 and without A-105
The second sheet. Comparing B2 with February!B2 would compare A-100 with A-104.

Instead of comparing by position, look up each SKU on the other sheet and bring its price next to the January price. In C2 on the January sheet:

=XLOOKUP(A2, February!A:A, February!B:B, "missing")

Then compare as before, and say when a SKU is not there at all:

=IF(C2="missing", "Not in February", IF(B2=C2, "Same", "Different"))
January sheet with February prices looked up by SKU; A-105 shows Not in February
Now the order of the February sheet does not matter.

XLOOKUP is in Microsoft 365 and Excel 2021 or later. In older versions use =IFERROR(VLOOKUP(A2, February!A:B, 2, FALSE), "missing"). Both return the first match, so if a SKU appears twice on the February sheet you only see one of its prices.

The lookup only goes one way: it finds what is missing in February, not what is new there. To find A-106, do the same on the February sheet and look up its SKUs in January. If the sheets have more than one column to compare, the next sections are quicker.

4. Why equal-looking values come out “Different”

When the formula says “Different” but you see the same value, the cells usually hold something other than what they show:

Four rows where values look the same but compare as FALSE or TRUE, with the reason
B2=C2 compares what is stored in the cell, not what you see.
  • A number stored as text (often with a small green triangle) is never equal to a number. Convert it with Data → Text to Columns → Finish, or compare both as numbers: =VALUE(B2)=VALUE(C2).
  • A space at the end, or a non-breaking space copied from a web page. Compare TRIM(SUBSTITUTE(B2, CHAR(160), " ")) instead of B2. When XLOOKUP returns #N/A for a value you can see, the causes are the same: why VLOOKUP returns #N/A.
  • A date in one column and text that looks like a date in the other, common after importing a CSV. Turn the text into a date with Text to Columns (choose the date order in step 3).
  • Letter case goes the other way: = says acme and ACME are the same. Use EXACT if they must not be.

5. Many columns or many rows: let a tool pair the rows

The lookup in section 3 is one formula per column, and with tens of thousands of rows whole-column lookups get slow. If both sheets come from an export, there is a shorter way:

  1. Save each sheet as CSV (File → Save As → CSV UTF-8).
  2. Drop the old file and the new file into Calamo's free compare tool. It pairs the rows by the ID column, here sku, so the order does not matter.
  3. You get added rows, removed rows and every changed cell with its old and new value, for all columns at once.
Calamo result for the two price lists: 1 row added, 1 removed, 2 changed, 3 unchanged, and the two price changes
The same two price lists in Calamo: A-106 added, A-105 removed, two prices changed.

The files are read in your browser and not uploaded. To try it with the example from this guide, download prices-january.csv and prices-february.csv.

Comparing whole sheets with many columns? See how to compare two Excel sheets for differences and how to find added, removed and changed rows.

Questions

How do I compare two columns in Excel for differences?

Put =IF(B2=C2, "Same", "Different") in an empty column and fill it down. To colour the differences instead, select both columns and add a conditional formatting rule with the formula =$B2<>$C2.

How do I compare two columns on different sheets?

If the rows are in the same order, refer to the other sheet directly: =IF(B2=February!B2, "Same", "Different"). If they are not, look up each row by its ID first: =XLOOKUP(A2, February!A:A, February!B:B, "missing"), then compare the result.

Is the comparison case-sensitive?

No. B2=C2 treats acme and ACME as equal. Use =EXACT(B2, C2) when letter case matters.

Sources

  1. IF function – Microsoft Support: https://support.microsoft.com/en-us/office/if-function-69aed7c9-4e8a-4755-a9bc-aa8bbff73be2
  2. EXACT function – Microsoft Support: https://support.microsoft.com/en-us/office/exact-function-d3087698-fc15-4a15-9631-12575cf29926
  3. XLOOKUP function – Microsoft Support: https://support.microsoft.com/en-us/office/xlookup-function-b7fd680e-6d10-43e6-84f9-88eae8bf5929
  4. Use conditional formatting to highlight information – Microsoft Support: https://support.microsoft.com/en-us/office/use-conditional-formatting-to-highlight-information-in-excel-fed60dfa-1d3f-4e13-9ecb-f1951ff89d7f
  5. Go To Special (Row differences) – Microsoft Support: https://support.office.com/en-us/article/2d686424-6150-4015-a8e4-a5990f4d7e3a
  6. Keyboard shortcuts in Excel – Microsoft Support: https://support.microsoft.com/en-us/office/keyboard-shortcuts-in-excel-1798d9d5-842a-42b8-9c99-9b7213f0040f
  7. How to find and highlight row differences in Microsoft Excel – How-To Geek: https://www.howtogeek.com/739417/how-to-find-and-highlight-row-differences-in-microsoft-excel/
Michal Piják
Michal PijákData engineer and the maker of Calamo. These guides come from comparing exports at work: every formula and command is checked against the linked documentation. Found a mistake? hello@calamo.io