Find the differences between 2 Excel worksheets?

Excel

Excel Problem Overview


I have two excel files with the same structure: they both have 1 column with data. One has 800 records and the other has 805 records, but I am not sure which of the 5 in the 805 set are not in the 800 set. Can I find this out using Excel?

Excel Solutions


Solution 1 - Excel

vlookup is your friend!

Position your column, one value per row, in column A of each spreadsheet. in column B of the larger sheet, type

=VLOOKUP(A1,'[Book2.xlsb]SheetName'!$A:$A,1,FALSE)

Then copy the formula down as far as your column of data runs.

Where the result of the formula is FALSE, that data is not in the other worksheet.

Solution 2 - Excel

It might seem like a hack, but I personally prefer copying the cells as text (or exporting as a CSV) into http://winmerge.org/">Winmerge</a> or any other diff tool. Assuming the two sheets contain mostly identical data, Winmerge will show the differences immediately.

Solution 3 - Excel

LibreOffice provides a Workbook Compare feature: Edit -> Compare Document

Solution 4 - Excel

Easy way: Use a 3rd sheet to check.

Say you want to find differences between Sheet 1 and Sheet 2.

  1. Go to Sheet 3, cell A1, enter =IF(Sheet2!A1<>Sheet1!A1,"difference","").
  2. Then select all cells of sheet 3, fill down, fill right.
  3. The cells that are different between Sheet 1 and Sheet 2 will now say "difference" in Sheet 3.

You could adjust the formula to show the actual values that were different.

Solution 5 - Excel

Excel has this built in if you have an excel version with the Inquire add-in.

This link from office webpage describes the process of enabling the add-in, if it isn't activated, and how to compare two compare two workbooks - among other things.

The comparison shows both structural differances as well as editorial and a lot of other changes if http://office.microsoft.com/en-us/excel-help/what-you-can-do-with-spreadsheet-inquire-HA102835926.aspx

Solution 6 - Excel

you should try this free online tool - www.cloudyexcel.com/compare-excel/

works good for most of the time, sometimes the results are a little off.

plus it also gives a good visual output

enter image description here

You can also download the results in excel format. (you need to signup for that)

Solution 7 - Excel

COUNTIF works well for quick difference-checking. And it's easier to remember and simpler to work with than VLOOKUP.

=COUNTIF([Book1]Sheet1!$A:$A, A1) 

will give you a column showing 1 if there's match and zero if there's no match (with the bonus of showing >1 for duplicates within the list itself).

Solution 8 - Excel

If you have Microsoft Office Professional Plus 2013, you can use Microsoft Spreadsheet Compare to run a report on the differences between two workbooks.

Launch Spreadsheet Compare:

In Windows 7: On the Windows Start menu, under Office 2013 Tools, click Spreadsheet Compare.

In Windows 8: On the Start screen, click Spreadsheet Compare. If you do not see a Spreadsheet Compare tile, begin typing the words Spreadsheet Compare, and then select its tile.

Compare two Excel workbooks:

  1. Click Home > Compare Files.
  2. a. Click the blue folder icon next to the Compare box to browse to the location of the earlier version of your workbook. (In addition to files saved on your computer or on a network, you can enter a web address to a site where your workbooks are saved.)
  3. b. Click the green folder icon next to the To box to browse to the location of the workbook that you want to compare to the earlier version, and then click OK. (TIP You can compare two files with the same name if they're saved in different folders.)
  4. In the left pane, choose the options you want to see in the results of the workbook comparison by checking or unchecking the options, such as Formulas, Macros, or Cell Format. Or, just Select All.

Reference:

https://support.office.com/en-us/article/Basic-tasks-in-Spreadsheet-Compare-f2b20af8-a6d3-4780-8011-f15b3229f5d8

Solution 9 - Excel

Use the vlookup function.

Put both sets of data in the same excel file, on different sheets. Then, in the column next to the 805 row set (which I assume is on sheet2), enter

=if(isna(vlookup(A1, Sheet1!$A$1:$A$800, 1, false)), 0, 1)

The column will contain 0 for values that are not found in the other sheet, and 1 for values that are. You can sort the sheet to find all the missing values.

Solution 10 - Excel

I think your best option is a freeware app called Compare IT! .... absolutely brilliant utility and dead easy to use. http://www.grigsoft.com/wincmp3.htm

Solution 11 - Excel

SO in fact that you are using excel means that you can use the SpreadSheet Compare from Microsoft. It is available from Office 2013. Yes i know this question is older then 6 years. But who knows maybe someone need this information today.

Solution 12 - Excel

The Notepad++ compare plugin works perfectly for this. Just save your sheets as .csv files and compare them in Notepad++. Notepad++ gives you a nice visual diff.

Solution 13 - Excel

May be this replay is too late. But hope will help some one looking for a solution

What i did was, I saved both excel file as CSV file and did compare with Windiff.

Solution 14 - Excel

ExcelDiff exports a HTML report in a Divided (Side-by-side) or Merged (Overlay) view highlighting the differences as well as the row and column.

Solution 15 - Excel

I used Excel Compare. It is payware, but they do have a 15 day trial. It will report amended rows, added rows, and deleted rows. It will match based on the worksheet name (as an option):

http://www.formulasoft.com/excel-compare.html

Solution 16 - Excel

Use conditional formatting to highlight the differences in excel.

Here's an example.

Solution 17 - Excel

With just one column of data in each to compare a PivotTable may provide much more information. In the image below ColumnA is in Sheet1 (with a copy in Sheet2 for the sake of the image) and ColumnC in Sheet2. In each sheet a source flag has been added (Columns B and D in the image). The PT has been created with multiple consolidation ranges (Sheet1!$A$1:$B$15 and Sheet2!$C$1:$D$10):

SO1500153 exaple

The left hand numeric column shows what is present in Sheet1 (including q twice) and the right what in Sheet2 (again with duplicates – of c and d). d-l are in Sheet1 but not Sheet2 and w and z are in Sheet2 (excluding those there just for the image) but not Sheet1. Add display Show grand totals for columns and control totals would appear.

Solution 18 - Excel

I found this command line utility that doesn't show the GUI output but gave me what I needed: https://github.com/na-ka-na/ExcelCompare

Sample output (taken from the project's readme file):

> excel_cmp xxx.xlsx yyy.xlsx
DIFF  Cell at     Sheet1!A1 => 'a' v/s 'aa'
EXTRA Cell in WB1 Sheet1!B1 => 'cc'
DIFF  Cell at     Sheet1!D4 => '4.0' v/s '14.0'
EXTRA Cell in WB2 Sheet1!J10 => 'j'
EXTRA Cell in WB1 Sheet1!K11 => 'k'
EXTRA Cell in WB1 Sheet2!A1 => 'abc'
EXTRA Cell in WB2 Sheet3!A1 => 'haha'
----------------- DIFF -------------------
Sheets: [Sheet1]
Rows: [1, 4]
Cols: [A, D]
----------------- EXTRA WB1 -------------------
Sheets: [Sheet1, Sheet2]
Rows: [1, 11]
Cols: [B, K, A]
----------------- EXTRA WB2 -------------------
Sheets: [Sheet1, Sheet3]
Rows: [10, 1]
Cols: [J, A]
-----------------------------------------
Excel files xxx.xlsx and yyy.xlsx differ

Solution 19 - Excel

Tried to find a tool that will help to extract only the different sheets with the cell difference highlighted. Could not find any, so ended up writing one for myself. I hope this helps someone who is looking for similar solution. It takes care of left/right unique sheets, identical/different size sheets.

import pandas as pd
import xlsxwriter
import numpy as np
from openpyxl import load_workbook

# Get a complete list of sheets from both WorkBook
BOOK1 = "Book_1.xlsx"
BOOK2 = "Book_2.xlsx"

xlBook1 = pd.ExcelFile(BOOK1)
sheetsBook1 = xlBook1.sheet_names
xlBook2 = pd.ExcelFile(BOOK2)
sheetsBook2 = xlBook2.sheet_names

sheets = list(set(sheetsBook1 + sheetsBook2))

with pd.ExcelWriter('Difference.xlsx', engine='xlsxwriter', mode='w') as writer:
    for sheet in sheets:
        print (sheet)

        book1 = None
        book2 = None
        book1Exists = True
        book2Exists = True

        try:
            book1 = pd.read_excel(BOOK1,sheet_name=sheet,header=None,index_col=False).fillna(' ')
        except ValueError as ve:
            book1Exists = False
        try:
            book2 = pd.read_excel(BOOK2,sheet_name=sheet,header=None,index_col=False).fillna(' ')
        except ValueError as ve:
            book2Exists = False

        # Case 1: Both sheet exist and they are identical size
        if ( (( (book1Exists == True) and (book2Exists == True) )) and 
            ( (len(book1) == len(book2)) and (len(book1.columns) == len(book2.columns)) )):


                comparevalues = book1.values == book2.values
                if False in comparevalues:
                    rows,cols = np.where(comparevalues==False)

                    for item in zip(rows,cols):
                        book1.iloc[item[0],item[1]] = ' {} --> {} '.format(book1.iloc[item[0], item[1]], book2.iloc[item[0],item[1]])

                    book1.to_excel(writer,sheet_name=sheet,index=False,header=False)
                    
                    # Get the xlsxwriter workbook and worksheet objects.
                    workbook  = writer.book
                    worksheet = writer.sheets[sheet]
                    
                    # Add a format. Light red fill with dark red text.
                    format1 = workbook.add_format({'bg_color': '#FFC7CE',
                                                   'font_color': '#9C0006'})

                    # Apply a conditional format to the cell range.
                    worksheet.conditional_format('A1:AZ100',{'type':     'text',
                                                  'criteria': 'containing',
                                                  'value':    '-->',
                                                  'format':   format1}) 

        # Case 2: Left unique case        
        elif (book1Exists == False):
            book2.to_excel(writer,sheet_name=sheet+" B2U",index=False,header=False)
        
        # Case 3: Right unique case        
        elif (book2Exists == False):
            book1.to_excel(writer,sheet_name=sheet+" B1U",index=False,header=False)
        
        # Case 4: Both exist but different size
        elif (( (book1Exists == True) and (book2Exists == True) ) and 
            ( (len(book1) != len(book2)) or (len(book1.columns) != len(book2.columns)) )):
            if (book1.size > book2.size):
                book1.to_excel(writer,sheet_name=sheet+" SD",index=False,header=False)
            elif (book2.size > book1.size):
                book2.to_excel(writer,sheet_name=sheet+" SD",index=False,header=False)
            

Solution 20 - Excel

excel overlay will put both spreadsheets on top of each other (overlay them) and highlight the differences.

http://download.cnet.com/Excel-Overlay/3000-2077_4-10963782.html?tag=mncol

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionXaisoftView Question on Stackoverflow
Solution 1 - ExcelNickSentowskiView Answer on Stackoverflow
Solution 2 - ExcelJulietView Answer on Stackoverflow
Solution 3 - Excelarober11View Answer on Stackoverflow
Solution 4 - ExcelkruboView Answer on Stackoverflow
Solution 5 - ExcelMarcusView Answer on Stackoverflow
Solution 6 - ExcelShashank SinglaView Answer on Stackoverflow
Solution 7 - ExcelhawbslView Answer on Stackoverflow
Solution 8 - ExcelJacob Kalakal JosephView Answer on Stackoverflow
Solution 9 - ExcelAbtin ForouzandehView Answer on Stackoverflow
Solution 10 - Excelxman_livesView Answer on Stackoverflow
Solution 11 - ExcelMchoetiView Answer on Stackoverflow
Solution 12 - Exceljava-addict301View Answer on Stackoverflow
Solution 13 - ExcelKBBWriteView Answer on Stackoverflow
Solution 14 - Exceluser2601995View Answer on Stackoverflow
Solution 15 - ExcelSunView Answer on Stackoverflow
Solution 16 - Exceleric.a.boothView Answer on Stackoverflow
Solution 17 - ExcelpnutsView Answer on Stackoverflow
Solution 18 - ExcelDoug HarrisView Answer on Stackoverflow
Solution 19 - ExcelAspak RogatiyaView Answer on Stackoverflow
Solution 20 - ExcelSauronView Answer on Stackoverflow