Hi everyone,
I am trying to write vlookup code between two workbooks by browsing the file from the user.
But Im getting error in the below line
set lookfor= book1.Sheets(1).Range(Cells(3,4),Cells(Last row, 4))
public Sub Command Button1_Click()
pathTxtBox1.Text=""
desPathName1 = Application.getOpenFilename()
path.TxtBox1.Text = desPathName1
End Sub
public Sub Command Button2_Click()
pathTxtBox1.Text=""
desPathName2 = Application.getOpenFilename()
path.TxtBox2.Text = desPathName2
End Sub
Public Sub Command Button3_Click()
Dim fnameAndPath As Variant
Dim fnameAndPath1 As Variant
Dim book1 as Workbook
Dim book2 as Workbook
Dim lookfor as Range
Dim ScrhRange as Range
set book1 = Workbooks.Open(pathTxtBox1.Text,true, false)
set book2 = Workbooks.Open(pathTxtBox2.Text,true, false)
set lookfor= book1.Sheets(1).Range(Cells(3,4),Cells(Last row, 4))
set ScrhRange = book2.Sheets(1).Range("A:D")
lookfor.Offset(0,1).Value= Application.Vlookup(lookfor,srchRange, 2 , False)
End sub
It opens two files,but Im getting Application or object-defined error.Can anyone please help me to resolve this.
Thanks in advance
Bookmarks