Hi all,
Im a novice in VB Script. I need some help.
The scenario is, i have 2 excel files. And both will/should have same number of worksheets.
1st worksheet of file A should be matched with 1st worksheet of file B in such a way that,
The cell A1 should be checked with all the cells of 1st column in file B
--> if A1's value is not found in the 1st column of file B, then it should be highlighted.
Example:
File A
Name Empcode
John 3333
david 1111
file B
Name Empcode
David 1111
Here as u can see david is in 2nd cell of File A's 1st column, whereas David is present in 1st cell of file B's column A. Hence cell to cell comparision (which is found in web) is not suitable.
Well, i surfed much and got some codes and i altered it according to my need. And i have highlighted the portion where im stuck (in different colors)
dim path1,path2, strCount, objDialog, intResult Set objDialog = Createobject("Useraccounts.Commondialog")
objDialog.Filter = "All files|*.*"
objDialog.Filterindex = 1
MsgBox "select first input file.. "
intResult = objDialog.Showopen
IF(intResult = 0) THEN
Wscript.quit
ELSE
path1= objDialog.FileName
MsgBox "select second input file.. "
intResult = objDialog.Showopen
IF(intResult = 0) THEN
Wscript.quit
ELSE
path2= objDialog.FileName
END IF
End If dim objWorkbook1, objWorkbook2, objWorksheet1, objWorksheet2, i,c_1, c_2 Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook1= objExcel.Workbooks.Open(path1)
Set objWorkbook2= objExcel.Workbooks.Open(path2) strCount = objworkbook1.Worksheets.Count
for i = 1 to strCount Set objWorksheet1= objWorkbook1.Worksheets(i) Set objWorksheet2= objWorkbook2.Worksheets(i) ' im stuck here
For Each c_1 In objWorksheet1.UsedRange
If c_1 <> objworksheet2.cell.value Then c_1.Interior.ColorIndex = 3 'Highlights in red color if any changes in cells
Else
c_1.Interior.ColorIndex = 0 End If
Next
Next set objExcel=nothing Please help me friends.