VLOOKUP From 2nd file in a macro

kcleere

Active Member
Joined
Oct 4, 2006
Messages
314
I have a macro that uses VLOOKUP to bring data from a separate file to the working file. For this work the separate file has to be open. For what I do with it this works fine as I can control the process.

If I give this to a user they will have to remember to have both files open for the routie to work.

Is there a better way to do this as I suspect the way I'm doing it it is crude.

Have patience with be because I "record" macros and I'm not that good at writing the VBA code.

Thanks
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
You should be able to use something along the lines of:

'D:\[Plants.XLS]Plants'!C1:C3

as the second argument in the vlookup. The stuff in the [] is the file name, after that, but before the ! is the tab name. Hope this helps.
 
Upvote 0
I think that's effectively what I have now which is:

"'=vlookup(L2,'[Site data.xls]Site Data'!$C$2:$D$70,2,false"
 
Upvote 0
Have you tried adding the path info in there as well? In my case the file is located on the d drive, hence the D:\. Hope this helps.
 
Upvote 0
Thank you...it works perfectly now. I can make sure the user has the file on their hard disk in a specific location and this should to the trick.
 
Upvote 0
Yes, that's the one possible hurdle with this, but as long as that file is in the set location you will be fine. Glad we were able to get things working for you.
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,385
Members
448,956
Latest member
JPav

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