VLookup From Closed Workbook

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am trying to apply a vlookup formula to a closed workbookbook using this syntax ...

Code:
grm_crew1 = application.WorksheetFunction.VLookup(b_label,'D:\WSOP 2020\SupportData\[Facilities.xlsx]Facilities'!range("H:M"),6,false)

grm_crew is defined as string, b_label is string. The vlookup is being applied to columns H:M in the sheet ("Facilities"), in the workbook("Facilities.xlsx"), at the path ("D:\WSOP 2020\SupportData\") specified.

I am getting an "Expected: expression" error with the first apostrophe identified.

Looking to the kind folk here to help me identify where I went wrong.
 
OK ... I'm not done with you guys yet! New approach, adapted code .... it results in a #NAME error in Z1.

Code:
ws_thold.Range("Z1") = "=VLookup(b_label,('D:\WSOP 2020\SupportData\[Facilities.xlsx]Facilities'!H:M),6,false)"

I'm guessing I'm missing something very subtle.
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
missing the !

VBA Code:
ws_thold.Range("Z1") = "=VLookup(b_label,('D:\WSOP 2020\SupportData\[Facilities.xlsx]!Facilities'!H:M),6,false)"
 
Upvote 0
missing the !

VBA Code:
ws_thold.Range("Z1") = "=VLookup(b_label,('D:\WSOP 2020\SupportData\[Facilities.xlsx]!Facilities'!H:M),6,false)"
Hmmmm ... didn't seem to help. #NAME (error 2029)

Code:
ws_thold.Range("Z1") = "=VLookup(b_label,('D:\WSOP 2020\SupportData\[Facilities.xlsx]!Facilities'!H:M),6,false)"
 
Upvote 0
Try
VBA Code:
ws_thold.Range("Z1") = "=VLookup(" & b_label & ",'D:\WSOP 2020\SupportData\[Facilities.xlsx]Facilities'!H:M,6,false)"
 
Upvote 0
Hmmm ... gremlins still at play here ...

This is what is in cell Z1 after running the code ...
=VLOOKUP(Auburn Diamond,'d:\WSOP 2020\SupportData\[Facilities.xlsx]Facilities'!H:M,6,FALSE)

My code to put it there ....
Code:
ws_thold.Range("Z1") = "=VLookup(" & b_label & ",'D:\WSOP 2020\SupportData\[Facilities.xlsx]Facilities'!H:M,6,false)"

I checked my data. "Auburn Diamond" is found in Facilities worksheet at Cell H2. The Result of the vlookup should be CWP as found in cell M2.
 
Upvote 0
What do you see in Z1 after you have run that line?
 
Upvote 0
Forgot the extra quotes
VBA Code:
ws_thold.Range("Z1") = "=VLookup(""" & b_label & """,'D:\WSOP 2020\SupportData\[Facilities.xlsx]Facilities'!H:M,6,false)"
 
Upvote 0
Solution
Applause! Gremlins evicted. Thanks Fluff!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,625
Messages
6,120,598
Members
448,973
Latest member
ksonnia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top