Custom Search

Wednesday, October 20, 2010

how to compare two excell sheets by using vbscript??

Set objExcel = CreateObject("Excel.application")
objExcel.Visible = True
Set objWorkbook1 = objExcel.workbooks.Open("C:\First.xls")
Set objWorkbook2 = objExcel.workbooks.Open("C:\Second.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
msgbox "value is different"
Else
msgbox "value is same"
End If
Next
objWorkbook1.close
objWorkbook2.close
objExcel.quit
set objExcel=nothing

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.