How to Compare Two Excel Sheets and Highlight Differences: 7 Methods

Method 1 – Using the View Side by Side Option to Compare Two Excel Sheets from Different Files and Highlight the Differences

Steps:
➤ Open the two workbooks simultaneously.

view side by side for different files

➤ Go to View Tab >> Window Dropdown >> View Side by Side Option

view side by side for different files

You will be able to view the two sheets at a time but they are aligned horizontally so we will change their alignment now.

view side by side for different files

➤ Go to View Tab >> Window Group >> Arrange All Option.

view side by side for different files

The Arrange Windows will open up.
➤ Select the Vertical option and press OK.

view side by side for different files

You can monitor the two sheets simultaneously, as shown below.

view side by side for different files

Select the cells of the SalesPerson column that have different names and change their background color.

view side by side for different files

Get the highlighted cells that show the different names of the salespersons.

view side by side for different files

Select the cells of the Sales column that have different values and change their background color.

view side by side for different files

Get the highlighted cells having different values in the two sheets.

view side by side for different files

One thing to mention is that if you have a large dataset and you want to scroll through the values of these sheets simultaneously then you have to follow this way.
➤ Go to View Tab >> Window Group >> Synchronous Scrolling Option.

compare two excel sheets and highlight differences


Method 2 – Utilizing Spreadsheet Compare Tool for Comparing Two Excel Sheets

Steps:
➤ Go to the Start screen, search for the Spreadsheet Compare app, and open it.

spreadsheet compare

A new window Spreadsheet Compare will open up.

spreadsheet compare
➤ Go to Home Tab >> Compare Files Option.

spreadsheet compare

The Compare Files wizard will open up, and here select the indicated sign beside the Compare box to browse the location of the January file.

spreadsheet compare

We have browsed the location of our January workbook.

spreadsheet compare

Choose the path of the file February workbook in the To box and press OK.

spreadsheet compare

Select the options (based on which you want to compare the values of the workbooks) from the left pane. We selected the Entered Values and Names option.

spreadsheet compare

Get the highlighted values that show the differences between the two sheets, and here you can see the two sheets side by side that you are comparing. You are getting the description that indicates the different cells and values.

compare two excel sheets and highlight differences

Note:
The Spreadsheet Compare option works for only Office Professional Plus 2013, Office Professional Plus 2016, Office Professional Plus 2019, and Microsoft 365 Apps.


Method 3 – Using the Compare and Merge Workbook Option

Step-01:
To enable the Compare and Merge Workbooks option, you have to follow this extra step.
➤ Go to Review Tab >> Share Workbook (Legacy) Option.

compare and merge

Then, the Share Workbook wizard will open up.
➤ Select the option “Use the old shared workbooks feature instead of the new co-authoring experience” and press OK.

compare and merge

Step-02:
Add the Compare and Merge Workbooks option to the Quick Access Toolbar.
Go to the File Tab.

compare and merge

➤ Select Options.

compare and merge

The Excel Options wizard will open up, and here select the Quick Access Toolbar option.
➤ Select the options serially, All Commands → Compare and Merge Workbooks → Add.

compare two excel sheets and highlight differences

The Compare and Merge Workbooks option will be added to the toolbar, and press OK.

compare and merge

Step-03:
➤ Go to your main workbook January and select the Compare and Merge Workbooks option from the toolbar.

compare and merge

From the dialog box select the copy of your January file, which is February, and press OK.

compare and merge

The changes we have made in the February workbook will appear in this workbook and those cells will be highlighted.

compare two excel sheets and highlight differences


Method 4 – Applying the View Side by Side Option to Compare Two Excel Sheets and Highlight Differences from the Same File

Steps:
➤ Go to View Tab >> Window Group >> New Window option.

view side by side option for the same file

A new workbook will open up which is basically the same workbook that is opened right now and a slight change of name will be done automatically. See that the name of the opened workbook became Compare Sheets-1 and the name of the new workbook is Compare Sheets-2.

view side by side option for the same file

Follow the procedures of Method-1, and then you will be able to highlight the differences.

view side by side option for the same file

When you close any one of the workbooks, then the changes will appear in the two sheets of the main workbook like below.

view side by side option for the same file

view side by side option for the same file


Method 5 – Using Conditional Formatting to Compare Two Excel Sheets and Highlight Differences

Steps:
➤Select the data range on which you want to apply the Conditional Formatting
➤Go to Home Tab >> Conditional Formatting Dropdown >> New Rule Option.

conditional formatting

The New Formatting Rule wizard will appear.
➤ Select Use a formula to determine which cells to format option and write the following formula in the Format values where this formula is true: box

=C5<>'February (2)'!C5

C5 is the first cell of the SalesPerson column, February (2) is the sheet name to which we want to compare and <> represents the Not Equal to operator.

➤ Click the Format option.

conditional formatting

The Format Cells dialog box will open up.
➤ Select Fill Option.
➤ Choose any Background Color and click OK.

conditional formatting

The Preview Option will be shown as below, and press OK.

conditional formatting

Get the highlighted cells in the SalesPerson column of the January (2) sheet.

conditional formatting

Highlight the different values of the Sales column.

compare two excel sheets and highlight differences


Method 6 – Inserting a Formula to Combine the Differences in Another Sheet

Steps:
➤ Create a sheet named Difference and select a cell in this sheet.

IF function

➤ Write the following formula in the selected cell

=IF('January (3)'!D6<>'February (3)'!D6,"January Sales:  "&'January (3)'!D6&CHAR(10)&"   February Sales:  "&'February (3)'!D6,"")

‘January (3)’! and ‘February (3)’! are the names of the sheets and when the values of the cells D6 will be not equal in these sheets then the corresponding values will be combined here otherwise IF will return a blank.

IF function

➤ Press ENTER and drag down the Fill Handle tool.

IF function

Get the different sales values for the January and February months.

IF function


Method 7 – Using a VBA Code to Compare Two Excel Sheets and Highlight Differences

Step-01:
➤ Go to Developer Tab >> Visual Basic Option.

VBA Code

The Visual Basic Editor will open up.
➤ Go to Insert Tab >> Module Option

VBA Code

A Module will be created.

VBA Code

Step-02:
➤Write the following code

Sub highlightdifferences()

Dim Cell As Range

For Each Cell In Worksheets("January (4)").UsedRange
     If Not Cell = Worksheets("February (4)").Cells(Cell.Row, Cell.Column) Then
         Cell.Interior.Color = vbGreen
     End If
Next Cell

End Sub

We declared Cell as Range and used the VBA FOR Next loop for all of the used cells of the January (4) sheet, and the VBA IF statement will check the values of these cells with the values of the February (4). When the values are unequal, the color of those cells of the January (4) sheet will be changed to Green.

VBA Code

➤ Press F5.

Get the cells containing different values highlighted.

compare two excel sheets and highlight differences


Download Practice Workbook


Related Articles


<< Go Back to Highlight in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Tanjima Hossain
Tanjima Hossain

TANJIMA HOSSAIN is a marine engineer who enjoys working with Excel and VBA programming. For her, programming is a handy, time-saving tool for managing data, files, and online tasks. She's skilled in Rhino3D, Maxsurf C++, MS Office, AutoCAD, and Excel & VBA, going beyond the basics. She holds a B.Sc. in Naval Architecture & Marine Engineering from BUET and is now a content developer. In this role, she creates tech-focused content centred around Excel and VBA. Apart from... Read Full Bio

8 Comments
  1. Hello,

    Thank you very much for this code.

    Could you please help in comparing two tables in the same worksheet? For example, the ame second table starting at F4 for the example above.

    Many thanks

    • Hello, ALEJANDRO
      Thank you for your comment. We have got an effective solution for your problem. We have taken 2 tables in the same worksheet as you can see from the following image:

      image 1

      To compare between these 2 tables, you can use the following VBA code:

      Sub HighLight_Diff_in_same_Ws()
          Dim ws As Worksheet
          Dim cell_1 As Range, cell_2 As Range
          Set ws = ThisWorkbook.Sheets("Sheet1")
          
          For Each cell_1 In ws.Range("B5:D12")
              Set cell_2 = ws.Cells(cell_1.Row, cell_1.Column + 4)
              If Not (cell_1.Value = cell_2.Value) Then
                  cell_1.Interior.Color = vbGreen
                  cell_2.Interior.Color = vbGreen
              End If
          Next cell_1
      End Sub

      Note: You should modify the Worksheet Name, Range and Cells references according to your data table.

      Image 2

      When you run the VBA code, it will highlight the differences between the 2 tables in green color.

      Image 3

      I hope, this is the solution you were looking for. If you have further queries let us know in the comment section. We will solve them as soon as possible.

      Regards,
      Sourav Kundu.
      Exceldemy

  2. Hello, I am using excel compare tool and it generates a new file with range(A101
    B95
    B100
    B101
    C95
    C100
    C101
    D101
    ) of cells that have changed value.
    I would like to take the range and highlight the corresponding excel file cells which has these changes.

    • Hello Shan,

      To highlight the range with changes, you’ll need to use VBA to highlight the changed cells in the original Excel file.

      If the compare tool generates a range like (A101, B95, etc.). You’ll need to copy this list.
      Open the workbook where changes occurred. Then, run the following VBA script to loop through the list and highlight the cells.

      Sub HighlightChanges()
          Dim ws As Worksheet
          Dim rng As Range
          Dim cellAddresses As Variant
          Dim i As Integer
          
          ' Define the sheet and cell range to highlight
          Set ws = ThisWorkbook.Sheets("Sheet1")
          
          ' List of cell addresses
          cellAddresses = Array("A101", "B95", "B100", "B101", "C95", "C100", "C101", "D101")
          
          ' Loop through each address and highlight it
          For i = LBound(cellAddresses) To UBound(cellAddresses)
              ws.Range(cellAddresses(i)).Interior.Color = RGB(255, 255, 0) ' Highlight color
          Next i
      End Sub

      It will highlight the specified cells with a yellow background.

      Regards
      ExcelDemy

      • This is working great, however the CellAddresses is different every time, could be 5/10/11 any number. Is there a way to feed the cell addresses from an excel file(Range always starts from cell B3) so it is dynamic?

        • Avatar photo
          Shamima Sultana Sep 26, 2024 at 12:09 PM

          Hello Shan,

          Glad to hear. To dynamically feed cell addresses from an Excel file (starting at cell B3), you can modify the VBA code to read the list directly from that file.

          Sub HighlightChangesFromFile()
              Dim ws As Worksheet
              Dim changesWs As Worksheet
              Dim rng As Range
              Dim cellAddresses As Variant
              Dim i As Integer
              Dim lastRow As Long
          
              ' Define the sheet to highlight and the sheet with cell addresses
              Set ws = ThisWorkbook.Sheets("Sheet1")
              Set changesWs = Workbooks("ChangesFile.xlsx").Sheets("Sheet1") ' Adjust workbook name
              
              ' Get the last row in column B for dynamic range
              lastRow = changesWs.Cells(changesWs.Rows.Count, "B").End(xlUp).Row
              
              ' Get the range of addresses from B3 to the last row
              Set rng = changesWs.Range("B3:B" & lastRow)
              
              ' Loop through each address and highlight it
              For Each cell In rng
                  ws.Range(cell.Value).Interior.Color = RGB(255, 255, 0) ' Highlight color
              Next cell
          End Sub

          This will read the cell addresses from column B of the other file and highlights them in the current workbook. Remember to replace “ChangesFile.xlsx” with the actual name of your file.

          Regards
          ExcelDemy

  3. Or even copy the CellAddresses from this other excel file to the workbook where changes occurred then VBA can use that to build the array then color?

    • Hello Shan,

      To dynamically feed cell addresses from an Excel file (starting at cell B3), you can modify the VBA code to read the list directly from that file.

      Sub HighlightChangesFromFile()
          Dim ws As Worksheet
          Dim changesWs As Worksheet
          Dim rng As Range
          Dim cellAddresses As Variant
          Dim i As Integer
          Dim lastRow As Long
      
          ' Define the sheet to highlight and the sheet with cell addresses
          Set ws = ThisWorkbook.Sheets("Sheet1")
          Set changesWs = Workbooks("ChangesFile.xlsx").Sheets("Sheet1") ' Adjust workbook name
          
          ' Get the last row in column B for dynamic range
          lastRow = changesWs.Cells(changesWs.Rows.Count, "B").End(xlUp).Row
          
          ' Get the range of addresses from B3 to the last row
          Set rng = changesWs.Range("B3:B" & lastRow)
          
          ' Loop through each address and highlight it
          For Each cell In rng
              ws.Range(cell.Value).Interior.Color = RGB(255, 255, 0) ' Highlight color
          Next cell
      End Sub

      This will read the cell addresses from column B of the other file and highlights them in the current workbook. Remember to replace “ChangesFile.xlsx” with the actual name of your file.

      Regards
      ExcelDemy

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo