Type =IF(A2=B2,"Match","Different") in a blank cell next to the first row and copy it down. It returns Match when the two cells are the same and Different when they are not.
=IF(A2=B2,"Match","Different")
You often have two lists side by side, for example an old price list and a new one, or names from two systems. Comparing them by eye is slow and easy to get wrong. A simple formula next to the data tells you row by row whether the values are the same.
Step by step
- Click the first empty cell to the right of your data, for example C2.
- Type
=IF(A2=B2,"Match","Different")and press Enter. - Point at the bottom-right corner of C2 until the cursor becomes a black cross, then double-click or drag down to fill the formula for all rows.
- Read the results: Match means the two cells are equal, Different means they are not.
- If you want to see only the rows that differ, turn on a filter on the result column and choose Different.
Try it here
Examples
1 Compare two columns row by row
The formula checks whether the value in column A equals the value in column B on the same row. It returns Match or Different as text. Copy it down and you can filter or count the results.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Old price | New price | ||
| 2 | 10 | 10 | Match | |
| 3 | 12 | 15 | ||
| 4 | 8 | 8 | ||
| 5 | 20 | 20 | ||
| 6 | 5 | 7 | ||
| 7 | 9 | 9 | ||
| 8 | 14 | 14 | ||
| 9 |
=IF(A2=B2,"Match","Different")2 Count how many rows match
SUMPRODUCT compares the whole range A2:A8 with B2:B8 at once. Each equal pair counts as 1, so the result is the number of matching rows. It is a quick summary without adding a helper column.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | List 1 | List 2 | |||
| 2 | Ana | Ana | 5 | ||
| 3 | Ben | Ben | |||
| 4 | Cara | Dana | |||
| 5 | Dan | Dan | |||
| 6 | Eve | Eve | |||
| 7 | Finn | Gina | |||
| 8 | Gus | Gus | |||
| 9 |
=SUMPRODUCT(--(A2:A8=B2:B8))Other ways to do it
| Formula | Use it when |
|---|---|
=A2=B2 | You only need TRUE or FALSE and want the simplest possible check. |
=COUNTIF(B:B,A2)>0 | The two columns are not in the same order and you want to know whether each value in column A appears anywhere in column B. |
=EXACT(A2,B2) | The comparison must be case-sensitive, for example product codes where abc and ABC are different. |
Practise it
Free exercises with instant feedback. No sign-up needed.
Common mistakes
- The formula shows Different for values that look the same. One value may be text and the other a number, or one may have extra spaces. Use =TRIM(A2)=TRIM(B2) or check with =ISNUMBER(A2) and =ISNUMBER(B2).
- The comparison stops working after you copy the formula down. Make sure the cell references are relative (A2 and B2, not $A$2 and $B$2) so they move with each row.
- The result column shows #VALUE! or #NAME?. Check that the text in the formula is in straight quotes and that the function name is spelled correctly, for example IF, not IIF.
Questions people also ask
How do I compare two columns and highlight differences?
Select both columns, go to Home › Conditional Formatting › Highlight Cells Rules › Duplicate Values and choose Unique. That colours the cells that appear only once.
Can I compare two columns in different sheets?
Yes. Refer to the other sheet in the formula, for example =IF(A2=Sheet2!A2,"Match","Different").
How do I compare two lists that are in a different order?
Use =COUNTIF(B:B,A2)>0 to check whether each value from the first list exists anywhere in the second list, regardless of row position.
Functions used
Every formula on this page was checked by SheetSkill’s spreadsheet engine. All how-to guides