+ Reply to Thread
Results 1 to 6 of 6

Variable filename in vlookup

  1. #1
    Registered User
    Join Date
    01-28-2009
    Location
    New York, USA
    MS-Off Ver
    Excel 2007
    Posts
    46

    Question Variable filename in vlookup

    I have a spreadsheet file that is processed by my system every monody. I have another reporting tool to edit down the info however since this is populated weekly I have different versions each week. Weekly report - week 1, weekly report - week 2, and so on. in the reporting tool I enter "week 1" into cell "B1" but in my vlookup formulas I have to edit the file name path C:\recaps\weeklyreport - week1 with a find and replace each time I do it. Is there anyway I can edit my lookup formula to pull from a variable workbook and when I update cell “B1” the formula knows to pull from that workbook
    Last edited by Lizzietish11; 06-28-2010 at 04:08 PM. Reason: edit post name

  2. #2
    Registered User
    Join Date
    08-29-2007
    Posts
    47

    Re: Variable filename in vlookup

    If everything else is staying the same except for the file name, you might be able to use INDIRECT and CONCATENATE to accomplish this.

    Please Login or Register  to view this content.
    Look at the way the formula is constructed when you set up the vlookup normally.

    It should be something like 'Week1.xls'!$A$1:$B$100

    So with concatenate, you just need to create the rest of it as text, except for the part that will change. I added spaces below to make it a little more clear.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-28-2009
    Location
    New York, USA
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: Variable filename in vlookup

    worked perfectly thanks!

  4. #4
    Registered User
    Join Date
    05-02-2013
    Location
    Dublin
    MS-Off Ver
    Excel 2016
    Posts
    62

    Re: Variable filename in vlookup

    hi, i have also tried this solution but i get a #REF! when the spreadsheet is closed? It works fine when the sheet is open?

    Any ideas?

    Thanks

    =VLOOKUP("AP Total",INDIRECT(CONCATENATE("'K:\Finance\2013\AP\Workbooks\[Mar13 - ",LEFT(D111,4),"-",RIGHT(D111,4),".xlsx]Summary'!$A:$U")),3,FALSE)

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Variable filename in vlookup

    Ats,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  6. #6
    Registered User
    Join Date
    03-19-2016
    Location
    Philippines
    MS-Off Ver
    2013
    Posts
    1

    Re: Variable filename in vlookup

    Hi guys,

    I have the same problem. This is my vlookup formula.
    =VLOOKUP(B6,'C:\Users\Downloads\[150826.xlsx]Sheet1'!$B$1:$C$250,2,FALSE)

    I want "150825" would be variable.

    This is what I did
    =VLOOKUP(B6,INDIRECT(CONCATENATE("C:\Users\Downloads\[",D3,".xls]Sheet1'!$B$1:$C$250")),2,FALSE)
    150826 is located in D3
    However, it is not working. #REF! is the output.

    An advise is much appreciated. Thanks.

+ 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