We help IT Professionals succeed at work.

Compare 2 excel spreadsheets and highlight the differences

1,674 Views
Last Modified: 2014-08-07
Hi Experts:

I have an excel file with 2 sheets.  There are 10 columns in each sheet.  Columns in Sheet 1 and Sheet 2 are the same but the data is slightly different.  

Is it possible to compare the 2 sheets and highlight the rows or cells with a difference?  Is it possible to reach to a solution without a VBA or vbscript?  Is it possible to reach to a solution using vlookup or match or conditional formatting?

Thanks in advance.
Comment
Watch Question

Steven HarrisPresident

Commented:
Although it is easier with VBA, you can still use Conditional Formatting:

Select the first cell of Sheet 1 (A1) > Conditional Formatting > Use Formula:

=$A1<>Sheet2!$A1

This looks at Sheet1 cell A1 and if it is not the same as Sheet2 cell A1 then it will perform the formatting.  Apply formatting of your choice (cell fill, text font, etc.) and apply to workbook.

Fill down formatting to all cells in that column.  Rinse and repeat for each column, exchanging the $A1 for $B1, etc.

This applies formatting to Sheet 1 only, and will have to be repeated for Sheet 2 if you want to see highlighting there as well.
Glenn RayExcel VBA Developer
CERTIFIED EXPERT
Top Expert 2014

Commented:
Here's a sort-of quick-and-dirty solution; anything more elaborate will probably require VBA.

This example has two source sheets - Sheet1 and Sheet2 - and the data ranges from columns A through H.  This is only eight columns, but you could change the methods/formulas to extend to column J (ten columns).

1) Create a new sheet with the same header/column layout as your source sheets.  For example, I'm naming it "Common"
2) Insert the following formula in cell A2 and copy across and down as many rows as in Sheet1.
=IFERROR(VLOOKUP(Sheet1!A2,Sheet2!A:$H,1,FALSE),"")
You will see all the common values in both sheets, regardless of record location.

3) Add a new column to the right, label the top cell "Duplicate" and add this formula in row 2 and copy down:
=IF(SUMPRODUCT(--((A2:H2)=""))=0,"Yes","No")
This will show "Yes" or "No" if the row has full matches and is therefore a duplicate in both Sheet1 and Sheet2

4) Turn on data filtering and filter on the "Yes" values to simplify the sheet.

I've attached an example file that demonstrates this.  I'm still trying to develop a simple conditional formatting method to apply to the first sheet that will highlight values if there are no unique keys (i.e., the entire row vs. a unique field).

Regards,
-Glenn
EE-DuplicateRowsAcrossSheets.xlsx
Glenn RayExcel VBA Developer
CERTIFIED EXPERT
Top Expert 2014

Commented:
TSS:  What if the duplicate values on Sheet2 are in a different row?  Won't the conditional formatting rule fail after the first mis-match of common rows?
Steven HarrisPresident

Commented:
Glenn, you are correct, but was working based off of the OP's comment of "Columns in Sheet 1 and Sheet 2 are the same  but the data is slightly different."

I took this to mean that we would be comparing the same cells across sheets, i.e. Sheet 1 cell A1, to Sheet 2 cell A1, and so on.

Author

Commented:
Hi Glenn:

Thanks for the solution.  I am working on it to see if it works in my case.  I think I have blank spaces in the cells.  Can we use TRIM function in your formula?

Also it will be very helpful if we can highlight the differences in different worksheet.

Thanks
Glenn RayExcel VBA Developer
CERTIFIED EXPERT
Top Expert 2014

Commented:
If your data is "slightly different" due to extra spaces, I think it would be important to see that.  Otherwise, you should trim all the data on the suspect table before running the real comparison.

An example file with just a few rows of data would really help us provide an adequate solution.

-Glenn

Author

Commented:
Hi Glenn:

Here is the sample data file.

Thanks,
Sample-data.xlsx

Author

Commented:
Hi Glenn:

Any solution yet?

Thanks,
Excel VBA Developer
CERTIFIED EXPERT
Top Expert 2014
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Perfect

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.