patx6
New Member
Hi
I am a self-learner and very new for VBA. I am creating simple worksheet and part of my macro is using VLookup?? at Request to Dispatch date from another worksheet. Could you please assist me on this?
Sub VlookMultipleWorkbooks()
Dim lookFor As Range
Dim srchRange As Range
Dim book1 As Workbook
Dim book2 As Workbook
Dim book2Name As String
book2Name = "Submission1.xlsm"
Set book1 = ThisWorkbook
Set book2 = Workbooks(book2Name)
Set lookFor = book1.Sheets("Sheet1").Range("A2:A5")
Set srchRange = book2.Sheets("Sheet1").Range("K:F")
lookFor.Offset(0, 6).Value = Application.Vlookup(lookFor, srchRange, -5, False)
End Sub
It seems to work only the results turn up with #N/A. Files are attached.
Thanks
Patx6
I am a self-learner and very new for VBA. I am creating simple worksheet and part of my macro is using VLookup?? at Request to Dispatch date from another worksheet. Could you please assist me on this?
Sub VlookMultipleWorkbooks()
Dim lookFor As Range
Dim srchRange As Range
Dim book1 As Workbook
Dim book2 As Workbook
Dim book2Name As String
book2Name = "Submission1.xlsm"
Set book1 = ThisWorkbook
Set book2 = Workbooks(book2Name)
Set lookFor = book1.Sheets("Sheet1").Range("A2:A5")
Set srchRange = book2.Sheets("Sheet1").Range("K:F")
lookFor.Offset(0, 6).Value = Application.Vlookup(lookFor, srchRange, -5, False)
End Sub
It seems to work only the results turn up with #N/A. Files are attached.
Thanks
Patx6