VLookup From Closed Workbook

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
3,868
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

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

EFANYoutube

Board Regular
Joined
May 19, 2017
Messages
162
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)
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,526
Office Version
  1. 365
Platform
  1. Windows
Try
VBA Code:
grm_crew1 = Application.WorksheetFunction.VLookup(b_label, Range("'D:\WSOP 2020\SupportData\[Facilities.xlsx]Facilities'!H:M"), 6, False)
 

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
3,868
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
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.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,526
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Forgot to mention, the other workbook will need to be open.
 

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
3,868
Office Version
  1. 365
  2. 2016
Platform
  1. Windows

ADVERTISEMENT

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.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,526
Office Version
  1. 365
Platform
  1. Windows
You could put the formula in a cell & then assign the result to a variable.
 

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
3,868
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
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.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,526
Office Version
  1. 365
Platform
  1. Windows
Glad we could help & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,493
Messages
5,636,641
Members
416,932
Latest member
mm07

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
Top