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.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
try the file name in ""?
Excel Formula:
grm_crew1 = application.WorksheetFunction.VLookup(b_label,"'D:\WSOP 2020\SupportData\[Facilities.xlsx]Facilities'!range("H:M")",6,false)
 
Upvote 0
Try
VBA Code:
grm_crew1 = Application.WorksheetFunction.VLookup(b_label, Range("'D:\WSOP 2020\SupportData\[Facilities.xlsx]Facilities'!H:M"), 6, False)
 
Upvote 0
Hi EFANYoutube! Thanks for sharing your suggestion. That error is gone, but replace with a new one: "Expected: list separator or )"

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

In the range (as noted above in red.
 
Upvote 0
Forgot to mention, the other workbook will need to be open.
 
Upvote 0
Ohhh ... so I can't use the vlookup of a closed workbook in this way? I was avoiding having to open up the workbook to find a single value.
Thanks all! I'll have to try another approach.
 
Upvote 0
You could put the formula in a cell & then assign the result to a variable.
 
Upvote 0
Yeah ... that was where I think I was going to go Fluff. Thanks for confirming that approach for me. Saves me from heading toward a dead end like this idea turned out to be.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,412
Members
448,960
Latest member
AKSMITH

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