+ Reply to Thread
Results 1 to 9 of 9

Dynamically change name of source data in VLOOKUP

  1. #1
    Registered User
    Join Date
    11-02-2009
    Location
    Toronto
    MS-Off Ver
    Mac Excel 2007
    Posts
    12

    Dynamically change name of source data in VLOOKUP

    I need help dynamically changing the source of where my data comes from in a VLookup.

    I'm working off a document that aggregates data for each month of the year. The data for this comes from several different documents on a monthly basis.

    So I need my Vlookup to source from different documents.

    So for example, I would have this formula in the September2009 column that needs to reference the September 2009 document.

    =VLOOKUP(A5,'SourceData September2009.xls]National - FM'!$B$3:$F$69,2,0)

    But the next column needs to source from the October2009 document, so:

    =
    =VLOOKUP(A5,'SourceData October2009.xls]National - FM'!$B$3:$F$69,2,0)

    I feel like this is fairly simple, I just don't know how to do it. Thanks.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Dynamically change name of source data in VLOOKUP

    Something like:

    =VLOOKUP(A5,INDIRECT("'SourceData "&Text(B$1,"mmmmyyyy")&".xls]National - FM'!$B$3:$F$69"),2,0)

    where B1 contains a header with date in October of 2009 and can be copied across.

    Note: This only works, however, with source workbooks left open.

    To work with closed workbooks, you need to install a free addin from here: Morefunc.xll

    and use INDIRECT.EXT instead and put in complete path of document.
    Last edited by NBVC; 11-02-2009 at 12:13 PM.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    11-02-2009
    Location
    Toronto
    MS-Off Ver
    Mac Excel 2007
    Posts
    12

    Re: Dynamically change name of source data in VLOOKUP

    Ok, I'm trying the following, but it doesn't work.

    =VLOOKUP(A5,INDIRECT('["Indicateurs "&TEXT(B3,)&" "&TEXT(C1,0)&"2009"&".xls"]National - FM'!$B$3:$F$69,),2,0)

    The intention is for the document to reference the following document:

    Document: Indicateurs PECM September2009.xls (PECM is B3, and September is C1)
    Sheet: National - FM

    But instead, excel says that it can't find document: Indicateurs "&TEXT(B3,)&" "&TEXT(C1,0)&"2009"&".xls

    Which is clearly none existent.

    Any thoughts?

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Dynamically change name of source data in VLOOKUP

    Probably more like:

    =VLOOKUP(A5,INDIRECT("'[Indicateurs "&B3&" "&TEXT(C1,"mmmm")&"2009.xls]National - FM'!$B$3:$F$69"),2,0)

  5. #5
    Registered User
    Join Date
    11-02-2009
    Location
    Toronto
    MS-Off Ver
    Mac Excel 2007
    Posts
    12

    Re: Dynamically change name of source data in VLOOKUP

    That's awesome! Thanks so much.

    Question: why does the "PECM" portion (B5) not need to be in Text, but the month does. and why do I need to add "mmmm" in the Text?

    This is really helpful, thanks so much.

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Dynamically change name of source data in VLOOKUP

    Even though the cell, C1 with a date in it looks like a date, excel really sees that as a 5 digit number representing that date (try to format that cell as general and you will see the number code)... so when you try referencing that cell in a concatenation type function, it takes the 5 digit code and displays that instead.... The Text() function with the use of the "mmmm" forces the number to be re-converted to a value that looks like the date... the "mmmm" means "give me the full month name extracted from that value". If you were to custom format C1 to display month only, you would use the same "mmmm" format.

    So you don't need the Text() function when you are dealing strictly with text or the "underlying" excel number.... only need it when you want a specific format of the number to be shown in the concatenated string...

    .. long winded, but that's the short of it

  7. #7
    Registered User
    Join Date
    11-02-2009
    Location
    Toronto
    MS-Off Ver
    Mac Excel 2007
    Posts
    12

    Re: Dynamically change name of source data in VLOOKUP

    Thanks so much for the quick and very thorough reply.

    This was really really helpful!

  8. #8
    Registered User
    Join Date
    11-02-2009
    Location
    Toronto
    MS-Off Ver
    Mac Excel 2007
    Posts
    12

    Re: Dynamically change name of source data in VLOOKUP

    Btw, I'm trying to download the .ext plug-in, but I'm using a Excel 2008 for Mac.

    Any idea where I can find this plug in?

    thanks again!

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Dynamically change name of source data in VLOOKUP

    You download it from here:

    http://download.cnet.com/Morefunc/30...-10423159.html

    but not sure of the Mac 2008 compatability

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1