VLOOKUP from a closed workbook

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
Hello all. Thank you in advance for any help I will try and explain and I hope someone can help.
I have a book called book 1. I would like some VBA in book 1 which will vlookup column A in a closed workbook called Book 2 returning column g of book 2 in column g of book 1.

The only problem is I book 2 is formatted like Book2 DD/MM/YYYY.xlsx and I always need to open and lookup column G from book 2 with the previous days date or today -1.

With some google searches I can do this when the file is the same name but not when the file is today’s date minus 1 each day.

Can anyone help?

Thank you!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
The only problem is I book 2 is formatted like Book2 DD/MM/YYYY.xlsx
Are you sure? I don't think that is possible. "/" are not valid characters to be used in file names.

I can do this when the file is the same name but not when the file is today’s date minus 1 each day.
Post the code that you have that works for today's date, and we can show you how to adjust it for yesterday's date.
 
Upvote 0
Apologies it isn’t / it is underscores like this DD_MM_YYYY.

I don’t have any code at the minute. I do this with a VLOOKUP formula at the moment every day by going and finding the workbook from the previous day.

Open book 1
B2 is a VLOOKUP of A2, book2 previous days date, column G. Then I paste as values and close the workbook from the previous day.

Thanks
 
Upvote 0
So, is the exact format of the name of the file: "Book2 DD_MM_YYYY.xlsx"
Will the prefix ALWAYS be "Book2"?

Can you post an example of one of your hard-coded VLOOKUP formulas?
(I could just give you the piece that figures out the date, but then you would need to figure out the rest)?

That part look would look like:
Code:
="Book2 " & SUBSTITUTE(TEXT(TODAY()-1,"mm/dd/yyyy"),"/","_") & ".xlsx"
of course, you need to use the INDIRECT function with it.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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