Building on yesterday's podcast, life becomes considerably more complex if you need to use VLOOKUP to look into a different workbook based on a date. Episode 820 will show you why INDIRECT won't work and takes a look at how to use Harlan Grove's PULL function. Download the function from ftp://members.aol.com/hrlngrv/pull.zip
This blog is the video podcast companion to the book, Learn Excel 97-2007 from MrExcel. Download a new two minute video every workday to learn one of the 377 tips from the book!
This blog is the video podcast companion to the book, Learn Excel 97-2007 from MrExcel. Download a new two minute video every workday to learn one of the 377 tips from the book!
Transcript of the video:
Hey. Welcome back to the MrExcel netcast. I'm Bill Jelen.
Well, let's actually get to Keith's question.
Now, in yesterday's netcast, I showed how we could use INDIRECT to grab values from various worksheets in the current workbook, but Keith has the completely different problem.
Every day, his sales are saved to a new workbook.
So, he has workbooks, for example, called SALES20080807 and there will be a different workbook for every day, and he needs a VLOOKUP that's going to go grab the right workbook, and find the value and return the value.
Well, that's just not going to work.
We have INDIRECT.
Well, there's a couple of problems.
INDIRECT cannot look into a closed workbook.
So, what Keith would have to do, here on my second sheet, is actually keep all of those workbooks open, which probably is not realistic, and so what we're going to do is we're going to use a great function that was written by Harlan Grove.
Now, now you can just go out to Google and search for HARLAN GROVE PULL and you'll get to the code.
It's posted in several different places.
I took that code and I pasted it into Excel as a new user function called PULL, and the way that PULL works is, basically, I set up a concatenation here that builds the file name.
So, we have our DATE over in column A; in column C, I used the TEXT function, like we did yesterday, to convert that to the correct format; build the FILE NAME here; the worksheet name, SHEET1 all the time; and then the RANGE where we want to look up; and then, finally, the PULL function.
Basically, the PULL function becomes the second argument in VLOOKUP.
So, we PULL the ‘, the file name, the worksheet name, the ’, the bang character, the ! mark, and the range name.
That function will go out and open the file, and return the whole array to Excel.
Now, it's a bit slow.
It would work here if I'm just pulling one or two values from each worksheet for 30 days, but if you were looking up hundreds or thousands of these, the recap time would be impossible, but, if you have a few, great way to do this using Harlan Grove’s PULL function.
Well, I want to thank you for stopping by.
We'll see you next time for another netcast from MrExcel.
Well, let's actually get to Keith's question.
Now, in yesterday's netcast, I showed how we could use INDIRECT to grab values from various worksheets in the current workbook, but Keith has the completely different problem.
Every day, his sales are saved to a new workbook.
So, he has workbooks, for example, called SALES20080807 and there will be a different workbook for every day, and he needs a VLOOKUP that's going to go grab the right workbook, and find the value and return the value.
Well, that's just not going to work.
We have INDIRECT.
Well, there's a couple of problems.
INDIRECT cannot look into a closed workbook.
So, what Keith would have to do, here on my second sheet, is actually keep all of those workbooks open, which probably is not realistic, and so what we're going to do is we're going to use a great function that was written by Harlan Grove.
Now, now you can just go out to Google and search for HARLAN GROVE PULL and you'll get to the code.
It's posted in several different places.
I took that code and I pasted it into Excel as a new user function called PULL, and the way that PULL works is, basically, I set up a concatenation here that builds the file name.
So, we have our DATE over in column A; in column C, I used the TEXT function, like we did yesterday, to convert that to the correct format; build the FILE NAME here; the worksheet name, SHEET1 all the time; and then the RANGE where we want to look up; and then, finally, the PULL function.
Basically, the PULL function becomes the second argument in VLOOKUP.
So, we PULL the ‘, the file name, the worksheet name, the ’, the bang character, the ! mark, and the range name.
That function will go out and open the file, and return the whole array to Excel.
Now, it's a bit slow.
It would work here if I'm just pulling one or two values from each worksheet for 30 days, but if you were looking up hundreds or thousands of these, the recap time would be impossible, but, if you have a few, great way to do this using Harlan Grove’s PULL function.
Well, I want to thank you for stopping by.
We'll see you next time for another netcast from MrExcel.