How to Compare Two Excel Files: Step-by-Step Guide

Published: November 25, 2024 - 7 min read

Julian Alvarado

Need to find differences between Excel spreadsheets? This guide covers six methods to compare Excel files, from built-in tools to advanced formulas.

Using Spreadsheet Compare to Compare Excel Files

Microsoft Excel’s Spreadsheet Compare tool offers a straightforward way to identify differences between two workbooks.

Step 1. Open Spreadsheet Compare tool in Excel.

  • Launch Excel and click on the “Data” tab in the ribbon.
Excel Data tab showing spreadsheet compared to location
  • Look for the “Data Tools” group and select “Spreadsheet Compare.”
  • If you don’t see this option, you may need to install it from Office settings.

Step 2. Select the two Excel files for comparison.

  • In the Spreadsheet Compare window, click “Compare Files.”
  • Browse and select your first Excel file.
  • Repeat the process for the second file you want to compare.

Step 3. Choose comparison options.

  • Specify which elements to compare: formulas, cell formatting, macros, etc.
  • Select specific sheets or entire workbooks for comparison.
  • Adjust sensitivity settings for detecting differences.

Step 4. Analyze the results in the comparison view.

  • Review the side-by-side comparison of both files.
  • Differences are highlighted for easy identification.
  • Use the navigation pane to jump between discrepancies.

Comparing Excel Files with Formulas

How do I compare two sets of data in Excel for differences?

Step 1. Use the IF function to compare individual cells.

  • In a new column, enter this formula: =IF(A1=B1, “Match”, “Difference”)
Excel formula bar showing an IF function comparison example.
  • A1 and B1 represent cells from the two datasets you’re comparing.
  • Drag the formula down to apply to all rows.

Step 2. Implement EXACT function for case-sensitive comparisons.

  • For text comparisons where case matters, use: =EXACT(A1,B1)
The exact function implementation for case sensitive comparison?
  • This returns TRUE for exact matches, FALSE for differences.

Step 3. Utilize COUNTIF to find matching values across ranges.

  • To count matches between ranges, use: =COUNTIF(A1:A10,B1)
Countif function usage for range comparison
  • This formula counts how many times B1 appears in A1:A10.
  • Extend the range as needed for your datasets.

How do I compare two lists in Excel to find matches?

Step 1. Apply VLOOKUP function to find matching values.

  • Use this formula: =VLOOKUP(A1,Sheet2!$A$1:$B$100,2,FALSE)
Count if function usage for range comparisons
  • A1 is the lookup value, Sheet2!$A$1:$B$100 is the range to search.
  • Adjust range references based on your data location.

Step 2. Use INDEX and MATCH combination for more flexible comparisons.

  • Try this formula: =INDEX(Sheet2!$B$1:$B$100,MATCH(A1,Sheet2!$A$1:$A$100,0))
index function for fruit comparison.
  • This allows for non-sequential data and is more versatile than VLOOKUP.

Step 3. Implement SUMPRODUCT function for array-based comparisons.

  • For comparing entire columns, use:=SUMPRODUCT(–ISNUMBER(MATCH($A$1:$A$100, Sheet2!$A$1:$A$100, 0)))
Some product formula for array comparison
  • This counts the total number of matches between two columns.

Visual Comparison Methods in Excel

Visual methods can quickly highlight differences between Excel files.

Step 1. Enable View Side by Side feature.

  • Open both Excel files you want to compare.
  • Go to the “View” tab and click “View Side by Side.”
View side-by-side option in Excel's Review tab
  • Scroll through both sheets simultaneously to spot differences.
Two Excel sheets displayed side-by-side for comparison

Step 2. Use Conditional Formatting to highlight differences.

  • Select the range you want to compare in both sheets.
  • Go to “Home” > “Conditional Formatting” > “New Rule.”
Traditional formatting menu on the Home tab?
  • Choose “Use a formula to determine which cells to format.”
New dialogue for rules of conditional formatting?
  • Enter this formula: =A1<>Sheet2!A1
Former Land Chief for conditional format in comparison?
  • Select a format to highlight differences.

Step 3. Implement Go To Special tool to identify cell differences.

  • Select the range you want to compare.
  • Press F5 to open the “Go To” dialog.
Go to dialogue box showing a special option.
  • Click “Special” and select “Row differences” or “Column differences.”
VBA editor showing comparison in macro code?
  • Excel will highlight cells that differ between the selected ranges.

Automating Excel File Comparison with VBA

VBA (Visual Basic for Applications) can automate the comparison process for large or frequently compared files.

Step 1. Create a simple VBA macro for file comparison.

  • Press Alt + F11 to open the VBA editor.
  • Insert a new module and paste this basic comparison code:
Image2

vba

Copy

Sub CompareFiles()

    Dim wb1 As Workbook, wb2 As Workbook

    Dim ws1 As Worksheet, ws2 As Worksheet

    Dim rng1 As Range, rng2 As Range

    Dim cell As Range

    Set wb1 = Workbooks.Open(“C:PathToFile1.xlsx”)

    Set wb2 = Workbooks.Open(“C:PathToFile2.xlsx”)

    Set ws1 = wb1.Sheets(“Sheet1”)

    Set ws2 = wb2.Sheets(“Sheet1”)

    Set rng1 = ws1.UsedRange

    Set rng2 = ws2.UsedRange

    For Each cell In rng1

        If cell.Value <> rng2.Cells(cell.Row, cell.Column).Value Then

            cell.Interior.Color = vbYellow

        End If

    Next cell

    wb1.Save

    wb2.Close False

End Sub

Step 2. Customize the macro to compare specific ranges or sheets.

  • Modify the sheet and range references in the code to match your needs.
  • Add loops to compare multiple sheets if necessary.

Step 3. Implement error handling and reporting in the VBA code.

  • Add error handling to manage potential issues:

vba

Coefficient Excel Google Sheets Connectors
Try the Free Spreadsheet Extension Over 500,000 Pros Are Raving About

Stop exporting data manually. Sync data from your business systems into Google Sheets or Excel with Coefficient and set it on a refresh schedule.

Get Started

Copy

On Error GoTo ErrorHandler

    ‘ Your comparison code here

Exit Sub

ErrorHandler:

    MsgBox “An error occurred: ” & Err.Description

    Exit Sub

  • Create a summary report of differences:

vba

Copy

Dim diffCount As Long

diffCount = 0

‘ In your comparison loop:

If cell.Value <> rng2.Cells(cell.Row, cell.Column).Value Then

    diffCount = diffCount + 1

End If

‘ After the loop:

MsgBox “Total differences found: ” & diffCount

Leveraging Power Query for Excel File Comparison

Power Query offers a robust solution for comparing large datasets or multiple files.

Step 1. Import both Excel files into Power Query.

  • Go to “Data” > “Get Data” > “From File” > “From Workbook.”
PowerKiri Git Data Menu for file import.
  • Select and import the first Excel file.
  • Repeat for the second file.

Step 2. Merge queries to identify differences and similarities.

  • In Power Query Editor, select “Home” > “Merge Queries.”
  • Choose the tables to merge and select the common columns.
  • Pick an appropriate join kind (usually “Full Outer”).

Step 3. Create a comparison report using Power Query results.

  • Add custom columns to flag matches and differences.
  • Use the following formula to compare values: = if [Column1] = [Column2] then “Match” else “Difference”
  • Filter and sort the results to focus on discrepancies.

Third-Party Tools for Comparing Excel Files

While Excel offers built-in comparison features, third-party tools can provide additional functionality for complex comparisons.

Step 1. Research popular Excel comparison tools.

  • Look for tools like Beyond Compare, DiffEngineX, or Excel Compare.
  • Consider factors like price, features, and user reviews.

Step 2. Evaluate features and benefits of dedicated comparison software.

  • Check for capabilities like:
    • Multi-sheet comparisons
    • Visual difference highlighting
    • Automated report generation
    • Version control integration

Step 3. Test integration possibilities with existing Excel workflows.

  • Download trial versions of potential tools.
  • Assess how well they fit into your current processes.
  • Consider compatibility with your Excel version and other software.

Mastering Excel File Comparison

By applying these methods, you can efficiently compare Excel files for various purposes. Experiment with different techniques to find the best approach for your specific needs. Remember, the key to effective comparison is choosing the right method for your data size and complexity.

Ready to take your Excel data management to the next level? Get started with Coefficient for advanced data syncing and comparison capabilities that go beyond Excel’s built-in features.

Sync Live Data into Your Spreadsheet

Connect Google Sheets or Excel to your business systems, import your data, and set it on a refresh schedule.

Try the Spreadsheet Automation Tool Over 500,000 Professionals are Raving About

Tired of spending endless hours manually pushing and pulling data into Google Sheets? Say goodbye to repetitive tasks and hello to efficiency with Coefficient, the leading spreadsheet automation tool trusted by over 350,000 professionals worldwide.

Sync data from your CRM, database, ads platforms, and more into Google Sheets in just a few clicks. Set it on a refresh schedule. And, use AI to write formulas and SQL, or build charts and pivots.

Julian Alvarado Content Marketing
Julian is a dynamic B2B marketer with 8+ years of experience creating full-funnel marketing journeys, leveraging an analytical background in biological sciences to examine customer needs.
500,000+ happy users
Wait, there's more!
Connect any system to Google Sheets in just seconds.
Get Started Free

Trusted By Over 50,000 Companies