Compare 2 excel spreadsheets and highlight the differences

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.
Imran AsifAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steven HarrisPresidentCommented:
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.
0
Glenn RayExcel VBA DeveloperCommented:
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
0
Glenn RayExcel VBA DeveloperCommented:
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?
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Steven HarrisPresidentCommented:
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.
0
Imran AsifAuthor 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
0
Glenn RayExcel VBA DeveloperCommented:
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
0
Imran AsifAuthor Commented:
Hi Glenn:

Here is the sample data file.

Thanks,
Sample-data.xlsx
0
Imran AsifAuthor Commented:
Hi Glenn:

Any solution yet?

Thanks,
0
Glenn RayExcel VBA DeveloperCommented:
I tried my "quick and dirty" solution above and it appears to work; did you have issues?

The data can't be checked on a per-row basis for two reasons:
1) The data isn't sorted; two different amount values for the same person could be swapped on adjacent rows.  While this is literally a difference, taken as a set, it is not and one would not want to see any highlighting.
2) Extra data exists in Sheet1 that is not in Sheet2.  This would prevent sorting of data if one were to do a per-row check (as I noted previously with ThinkSpaceSolution's suggestion).

See the example file; I added a conditional formatting rule that highlights the entire row of data on Sheet1 if the "Duplicate" value on the "Common" sheet is "Yes."

Note:  If your Sheet1 has two rows for the same individual with different amounts (ex., 100 and 96) and Sheet2 has both of those values also, neither row will not be highlighted even if one value is changed to match the other.  For example, change cell E5 on sheet1 to 100 or 96; it won't highlight because both of those values exist for that person on the other sheet.

-Glenn
EE-Sample-Data.xlsx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Imran AsifAuthor Commented:
Perfect
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.