VB script to compare two excel sheets
16 Jul 2008 - 12:18:59 pm

ExcelFilePath1 = InputBox("Please Enter the Path of first Excel File")
   Set fso = CreateObject("Scripting.FileSystemObject")
   If (fso.FileExists(ExcelFilePath1) = false )Then
   msgbox  ExcelFilePath1 & " doesn't exist."

   wscript.quit
   End If

ExcelFilePath2 = InputBox("Please Enter the Path of second Excel File") 
If (fso.FileExists(ExcelFilePath2) = false )Then
   msgbox  ExcelFilePath2 & " doesn't exist."
   wscript.quit
End If




Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = false




Set objWorkbook1 = objExcel.Workbooks.Open(ExcelFilePath1)

Set objWorkbook2 = objExcel.Workbooks.Open(ExcelFilePath2)



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 green color if any changes in cells (for the first file)

           cell.Interior.ColorIndex = 4

'Highlights the same cell in the Second file

objWorksheet2.range(cell.Address).interior.colorIndex = 4

                          

       Else

           cell.Interior.ColorIndex = 0

       End If

   Next


ObjExcel.displayAlerts = False 



objExcel.Save

objExcel.quit



set objExcel=nothing


msgbox "It is Done"

Admin · 1103 views · 48 comments
Categories: VB Script, Excel Objects

Permanent link to full entry

http://automation-qtp.discussionsblog.com/QTP-b1/VB-script-to-compare-two-excel-sheets-b1-p9.htm

Comments

No comments are allowed in this blog


Leave a comment

No comments are allowed in this blog

Last Comment

Yes, Even I agree. Some of ...

2009-12-22 @ 05:59:03 pm
by siva


I agree, some of the answers ...

2009-11-09 @ 03:59:29 pm
by ashwani


Can anyone tell me how to ...

2009-03-01 @ 12:38:47 pm
by harshada


Hi Can anyone help me out ...

2008-11-20 @ 05:01:49 pm
by Ramesh


some of your answers are wrong....

2008-09-15 @ 03:28:25 pm
by avnish


please post HP0-M80 & HP0-M81 Sample ...

2008-08-22 @ 08:46:36 pm
by Test


Hi dhruv, ...

2008-07-28 @ 08:35:15 am
by suri


Hi all,

This blog is ...

2008-07-28 @ 06:47:17 am
by dhruv


hi experts, this is gud site.. from ...

2008-07-22 @ 11:19:25 pm
by rameshtt


Hi , Here I'm giving a ...

2008-07-17 @ 03:59:04 pm
by lavanya


You can do that by using ...

2008-07-17 @ 09:01:26 am
by suri


How to Highlight the textbox data 'To ...

2008-07-17 @ 08:58:30 am
by suri


Please provide answers to these questions

2008-07-16 @ 03:53:48 pm
by Sreekanth


Hi , ...

2008-07-16 @ 12:50:21 pm
by Admin


We can do the same in ...

2008-07-16 @ 12:34:07 pm
by Admin


Who's Online?

Member: 0
Visitor: 1

Announce

Tags

No tags in this Blog

rss Syndication

Archives