Compare two excel workbooks

mattwellings

New Member
Joined
Jun 27, 2011
Messages
2
Hi Guys, I have got a problem.

I am trying to compare two different excel workbooks by using a vbs script, the current script below is okay as it compares them.

But the issue is when a row has been shifted down, the script thinks that the data has changed and therefore highlights the row as red, but the data has only been moved down.

I have downloaded a programe called "Excel Compare" but as it is for a buisness i will need to buy a licese. What "Excel Compare" does is tell's you what data has been added and what data has been removed.

Code:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook1= objExcel.Workbooks.Open("C:\Users\")
Set objWorkbook2= objExcel.Workbooks.Open("C:\Users\")
msgbox"The comparison started!",64, "Excel Comparison"
Set objWorksheet1= objWorkbook1.Worksheets(1)
Set objWorksheet2= objWorkbook2.Worksheets(1)
   For Each cell In objWorksheet2.UsedRange
       If cell.value <> objWorksheet1.Range(cell.Address).Value Then
           cell.Interior.ColorIndex = 3
       Else
           cell.Interior.ColorIndex = 0
       End If
   Next
msgbox"The comparison has now complete!",64,"Excel Comparison"
set objExcel=nothing

Any help would be greatly appreciated.

Thanks :)
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Your comparison is working correctly if you want both sheets the same then you have to make the same changes to both

if you want to compare the data then you have to use a method of keying between the two sets
 
Upvote 0
The thing is i dont want them to be the same, there will be different data being added, and what i want is for the sript to tell me what data is new and what has been removed.

How do i do the method about keying between the two sets ?

Thanks for your response.
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,558
Members
452,928
Latest member
101blockchains

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top