PDA

View Full Version : Workbooks comparison



balumail75
06-02-2011, 06:42 AM
Every quarter I get the Excel workbook with lot of data in 14 worksheets.

I have linked the data to lot of ppt 2007 charts.

Please help me, If I want to compare the old workbook with new workbook, for verifying, if any rows have been inserted in between and cell locations are same in both the workbooks. Leave the value comparison.
So that the datas will be autoupdated correctly from the same locations from the new excel workbook.

Thanks for the help.

Reg,
Bala.

mikerickson
06-02-2011, 07:54 AM
Un tested, but maybe something like this.
Dim wb1 as Workbook, wb2 as Workbook
Dim ws1 as Worksheet, ws2 as Worksheet
Set wb1 = Workbooks("old book.xls")
Set wb2 = Workbooks("new book.xls")

For each ws1 in wb1.Sheets
Set ws2 = wb2.Sheets(ws1.Name)
with ws1
If .usedRange.Address <> ws2.UsedRange.Address Then
MsgBox "different"
End If

If .cells.specialcells(xlcelltypeformulas).address <> ws2.cells.specialcells(xlcelltypeformulas).address Then
MsgBox "different"
End If
End with
Next ws

balumail75
06-14-2011, 05:47 AM
If run the above code, I am getting "Subscript out of range" message. Please help me.

Reg,
Balu.

mikerickson
06-14-2011, 07:15 AM
Have the workbook names been adjusted to match your situation?

sathishesb
06-16-2011, 01:37 PM
:help i have given to excel files each has excalty has one sheet. Each sheet has 20 columns. Now my job is to compare any 3 columns dynamically of those 2 files and write the mismatching values in those columns in a 3rd excel file. Please help us with code guys plzzzz help me:help