Compare any two excel sheets, each cell by cell
This code will open two excel sheet(s) and compare each sheet, cell by cell. If there are any changes in cell(s) , it will highlight the cell in red color in the first sheet.
Set objExcel = CreateObject(”Excel.Application”)
objExcel.Visible = True
Set objWorkbook_1= objExcel.Workbooks.Open(”C:\Doc1.xls”)
Set objWorkbook_2= objExcel.Workbooks.Open(”C:\Doc2.xls”)
Set objWorksheet1= objWorkbook_1.Worksheets(1)
Set objWorksheet2= objWorkbook_2.Worksheets(1)
For Each cell In objWorksheet1.UsedRange
If cell.Value <> objWorksheet2.Range(cell.Address).Value Then
cell.Interior.ColorIndex = 3 'Highlights the specific cell in red color if any changes in cells
Else
cell.Interior.ColorIndex = 0
End If
Next
set objExcel=nothing
Tuesday, October 12, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment