How to Compare two Excel sheets cell by cell
Vote if this topic was useful to you
How to Compare two Excel sheets cell by cell
''This code will open two excel sheet and compare each sheet cell by cell, if any changes there in cells , it will highlight the cells in red color in the first sheet.
Set objExcel = CreateObject(“Excel.Application”)
objExcel.Visible = True
Set objWorkbook1= objExcel.Workbooks.Open(“C:\Users\sgajre\Desktop\ListOfTopics1.xls”)
Set objWorkbook2= objExcel.Workbooks.Open(“C:\Users\sgajre\Desktop\ListOfTopics2.xls”)
Set objWorksheet1= objWorkbook1.Worksheets(1)
Set objWorksheet2= objWorkbook2.Worksheets(1)
For Each cell In objWorksheet1.UsedRange
If cell.Value <> objWorksheet2.Range(cell.Address).Value Then
'Highlights in red color if any changes in cells
cell.Interior.ColorIndex = 3
Else
cell.Interior.ColorIndex = 0
End If
Next
set objExcel=nothing
Set objExcel = CreateObject(“Excel.Application”)
objExcel.Visible = True
Set objWorkbook1= objExcel.Workbooks.Open(“C:\Users\sgajre\Desktop\ListOfTopics1.xls”)
Set objWorkbook2= objExcel.Workbooks.Open(“C:\Users\sgajre\Desktop\ListOfTopics2.xls”)
Set objWorksheet1= objWorkbook1.Worksheets(1)
Set objWorksheet2= objWorkbook2.Worksheets(1)
For Each cell In objWorksheet1.UsedRange
If cell.Value <> objWorksheet2.Range(cell.Address).Value Then
'Highlights in red color if any changes in cells
cell.Interior.ColorIndex = 3
Else
cell.Interior.ColorIndex = 0
End If
Next
set objExcel=nothing
Similar topics
» How to search for a particular value in an Excel sheet
» How to delete columns range from the excel sheet
» Excel Sorting by Rows or/and Columns (Ascending or Descending)
» How to delete columns range from the excel sheet
» Excel Sorting by Rows or/and Columns (Ascending or Descending)
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Thu Jun 19, 2014 11:31 am by thomasdfg
» How to identify the object when it is dynamically changing behavior
Wed Jun 18, 2014 6:37 pm by thomasdfg
» Patches for QTP 10, 11, 11.5
Wed Jun 18, 2014 6:04 pm by thomasdfg
» Retrieving data from Txt file into datatable
Wed Jun 18, 2014 5:32 pm by thomasdfg
» VB Script to count number of links in a web page.
Wed Jun 18, 2014 4:51 pm by thomasdfg
» Customized HTML reports in QTP
Wed Jun 18, 2014 4:42 pm by thomasdfg
» how to print values into a field of a web page, from a data table in qtp?
Wed Jun 18, 2014 4:37 pm by thomasdfg
» How to delete cookies using QTP?
Wed Jun 18, 2014 4:30 pm by thomasdfg
» When UFT Does Not Identify an Object
Wed Jun 18, 2014 4:23 pm by thomasdfg