How to Compare Two Rows in Excel & Google Sheets

Written by

Editorial Team

Reviewed by

Laura Tsitlidze

Last updated on November 30, 2023

This tutorial demonstrates how to compare two rows in Excel and Google Sheets.

compare two rows final data

Shortcut to Select Differences

PC Shortcut:Ctrl+Shift+|
Mac Shortcut:+Shift+|
Select two rows. Pressing CTRL + SHIFT + | (pipe) changes the selection to just the cells that do not match in the second row.

See All Excel Shortcuts

Read on for how to apply formatting to the differences.

Compare Two Rows

Excel allows you to compare rows and highlight the similarities and differences using conditional formatting. In the following example, there are names in Rows 2 and 3.

compare two rows initial data

Say you want to compare the two rows above and highlight cells where the rows don’t match (Columns D, G, and H) in red.

  1. Select the data range you want to compare, and in the Ribbon, go to Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values.

compare two rows conditional formatting 1

  1. In the pop-up window, (1) select Unique and (2) click OK, leaving the default format (Light Red Fill with Dark Red Text).
    You could also have selected Duplicate and in that case, the same values would be highlighted.

compare two rows conditional formatting 2

As a result, cells containing different values in Rows 2 and 3 are highlighted in red.

compare two rows final data

Compare Two Rows in Google Sheets

You can also compare two rows using conditional formatting in Google Sheets.

  1. Select the data range you want to compare (here, C2:I3), and in the Menu, go to Format > Conditional formatting.

google sheets compare two rows conditional formatting

  1. In the window on the right side, (1) select Custom formula is under Format rules, and (2) enter the formula:
=C$2<>C$3

Then (3) click on the fill color icon, (4) choose red, and (5) click Done.

google sheets compare two rows conditional formatting 2

The formula has a dollar sign to fix rows, and only change columns. This means that the formatting rule will go column by column and compare cells in Rows 2 and 3.

As a result, cells with different values have a red fill color.

google sheets compare two rows final data

AI Formula Generator

Try for Free

See all How-To Articles