vlookup from another file location vba

GreenyMcDuff

Active Member
Joined
Sep 20, 2010
Messages
313
Hi there,

hopefully quite a simple question:

I am trying to vlookup some values into a sheet from a workbook located in another folder

Here is what I have so far:

Code:
    Range("H9").Select
        Selection.Resize(LastRow - 8).Formula = "=vlookup(Cells(9,2).Address(False,True),'N:\Sheet1 & Format(DateSerial(Year(Now), Month(Now()) - 1, 0), "mmyy").xls Summary (Net of Fees)'!$A:$M,3,0)"

As you can see the lookup needs to refer to a different file each month. I am fairly sure this is just a syntaxing issue so I would be grateful to anyone who can show me the light

Thanks

Chris
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Can you post the formula as you expect it to appear in the cell after running the macro.
 
Upvote 0
Here's a best guess...

Code:
Range("H9").Resize(LastRows - 8).Formula = _
"=vlookup(" & Cells(9, 2).Address(False, True) & ",'N:\Sheet1\[" & Format(DateSerial(Year(Now), Month(Now()) - 1, 0), "mmyy") & ".xls]Summary (Net of Fees)'!$A:$M,3,0)"
 
Upvote 0
Hi here's how I expect it to look:

=vlookup($B9,'N:\Sheet1 0711.xls'Summary!$A:$M,3,0)

I'm not entirely sure on the synatx to reference another workbook

Thanks for the replies

Chris
 
Upvote 0
The correct syntax would be like

=VLOOKUP($B9,'N:\Path\[filename.xls]SheetName'!$A:$M,3,0)
 
Upvote 0

Forum statistics

Threads
1,224,561
Messages
6,179,521
Members
452,923
Latest member
JackiG

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