• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3968
  • Last Modified:

vb script to compare data from 2 excel files and write a flag if a match is found.

I am trying to write a vb script code that will enable me to read and compare data from 2 excel files. if a matach is found i put a flag. All i need is the part where it binds to the 2 files, workbooks and worksheets. and how to do the comparison. is it like the normal boolean expressions like
if(sheet1.value = sheet2.value)
   They are equal
else
   Not Equal
endif
Example of the data..
File1                                                                  File 2
   Sheet1                                                                Sheet 1
       Col 2                                                                    col 6                       Flag
         45                                                                          23
         34                                                                          45                      Found a match
its something like this.

thank you.



0
amcurso
Asked:
amcurso
  • 2
2 Solutions
 
leonstrykerCommented:
This should get you started:

Dim wb1, wb2
Dim ws1, ws2
Dim xl

Set xl = CreateObject("Excel.Application")
Set wb1 = xl.Workbooks.Open("c:\myBook1.xls")
Set wb2 = xl.Workbooks.Open("c:\myBook2.xls")

Set wk1 = wbk1.Worksheets(1)
Set wk2 = wbk2.Worksheets(1)

Leon

0
 
leonstrykerCommented:
This site has some more useful samples on working with Excel from VBS

http://www.bygsoftware.com/Excel/VBA/vbs_script.htm

Leon
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now