+ Reply to Thread
Results 1 to 13 of 13

Vlookup and insert date from cell into file pathname

  1. #1
    Registered User
    Join Date
    03-10-2021
    Location
    Texas
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    9

    Vlookup and insert date from cell into file pathname

    I have a Vlookup formula that works, but now I want to have it read a date from a cell in the current worksheet, and make that date/string? part of the full path filename telling Vlookup where to look (in another workbook).
    The date is in cell B1 and I have named B1 "Date". It will never be today's date, it will always be a previous date. The filename is (using yesterday's date as an example)

    Summary Report_20100309.xlsx

    This is what I have:

    =VLOOKUP(M4,'[C:\2021\FILES\03\[Summary Report_&TEXT($Date)&.xlsx]Summary]'!$A:$D,4,0)

    How do I get it to recognize the string in B1 and make it part of the filename? Thank you!

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,734

    Re: Vlookup and insert date from cell into file pathname

    indirect() should do it, thats how i created a similar path in the past
    Not on a windows PC right now - on a MAC and not played with paths in a while
    =VLOOKUP(M4,INDIRECT("'[C:\2021\FILES\03\[Summary Report_"&B1&"'!$A:$D"),4,0)
    But that does fix all the path , and not just add the date part
    BUT you could split the path out to different cells if you wanted to change say the folder 2021 to 2022 etc
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    03-10-2021
    Location
    Texas
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    9

    Re: Vlookup and insert date from cell into file pathname

    Thanks... that did not work. I discovered that a full path name is not recognized; the file must be open. I played with it some more. The static filename+Sheetname is:
    Trips Summary Report_2021MMDD.xlsx]Summary
    I can get a formula to generate the variable filename by itself: =CONCATENATE("[Trips Summary Report_",INDIRECT("B1"),".xlsx]SUMMARY")
    (The variable date is in Cell B1)

    But inserting it into the VLOOKUP has me stumped:
    original VLOOKUP formula: =VLOOKUP(L4,'[Trips Summary Report_2021MMDD.xlsx]Summary'!$A:$D,4,0)
    I imagine it should be something like:
    =VLOOKUP(L4,'(CONCATENATE("[Trips Summary Report_",INDIRECT("B1"),".xlsx]SUMMARY")'!$A:$D,4,0)
    but that does not work.
    Thanks for any help!!

  4. #4
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,734

    Re: Vlookup and insert date from cell into file pathname

    perhaps a sample spread sheet attached with expected results
    does
    i assume the vlookup works if all hard coded
    what does the look like - full path including name and range
    and what bits are in a seperate cell

  5. #5
    Registered User
    Join Date
    03-10-2021
    Location
    Texas
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    9

    Re: Vlookup and insert date from cell into file pathname

    B1 is the variable date I want to be appended to Trips Summary Report_ ......
    M4 has the static Vlookup formula, which works.
    Attached Files Attached Files

  6. #6
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,734

    Re: Vlookup and insert date from cell into file pathname

    so this does NOT work
    =VLOOKUP(L4,INDIRECT("'P:/Data Analysts/Commercial/2021/GEOTAB FILES/03/[Trips Summary Report_"&B1&".xlsx]Summary'!$A:$D"),4,0)

  7. #7
    Registered User
    Join Date
    03-10-2021
    Location
    Texas
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    9

    Re: Vlookup and insert date from cell into file pathname

    No. I also tried taking the full path away; and that did not work, either. Both times, the summary report was open.

    =VLOOKUP(L4,INDIRECT("'[Trips Summary Report_"&B1&".xlsx]Summary'!$A:$D"),4,0)

  8. #8
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Vlookup and insert date from cell into file pathname

    What is exactly the file name and the tab name?
    could it be the value is not found in the target file?

  9. #9
    Registered User
    Join Date
    03-10-2021
    Location
    Texas
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    9

    Re: Vlookup and insert date from cell into file pathname

    Trips Summary Report_20210317.xlsx]Summary is there. When I hard-code it without trying to create it with the date in Cell B1, the formula executes just fine.

  10. #10
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Vlookup and insert date from cell into file pathname

    what if you try it like that? just for the test:
    =VLOOKUP(L4,INDIRECT("'[Trips Summary Report_"&"20210317"&".xlsx]Summary'!$A:$D"),4,0)

  11. #11
    Registered User
    Join Date
    03-10-2021
    Location
    Texas
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    9

    Re: Vlookup and insert date from cell into file pathname

    That works. =VLOOKUP(L4,INDIRECT("'[Trips Summary Report_"&"20210317"&".xlsx]Summary'!$A:$D"),4,0)
    Decided to go one step further and tried:
    =VLOOKUP(L4,INDIRECT("'[Trips Summary Report_"&$B$1&".xlsx]Summary'!$A:$D"),4,0)
    and it works!!
    Thank you Belinda!!

  12. #12
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Vlookup and insert date from cell into file pathname

    Wow that's great
    You're welcome

  13. #13
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,734

    Re: Vlookup and insert date from cell into file pathname

    EDIT
    Looks like while i was setting up examples and test
    you now have an answer

    Excel is able to use vlookup from closed spreadsheet - using a PATHNAME
    https://www.excelforum.com/excel-for...-workbook.html
    BUT indirect() needs the workbook to be open and wont work on closed workbooks
    https://www.excelforum.com/excel-for...-function.html

    Sorry I forget that in the past i used indirect.ext but that add-in was used with old version of excel 2010, i think i used on 2013 before
    But Not used recently
    Sorry for any confusion, you may need a VBA solution
    Last edited by etaf; 03-18-2021 at 04:01 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] vlookup formula - is it possible to insert a file name with just pointing to a cell
    By leroyas in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-09-2019, 11:17 AM
  2. [SOLVED] Varaible for file name or this file pathname
    By ratdogexcel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-26-2014, 12:17 PM
  3. Replies: 0
    Last Post: 08-16-2013, 12:04 PM
  4. [SOLVED] Relative file pathname in macro
    By ERoemer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-03-2013, 07:46 AM
  5. Vlookup to Insert photos compiled in a Folder to en Excel file
    By aleifer12 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-03-2012, 11:59 AM
  6. Replies: 0
    Last Post: 03-23-2006, 05:45 PM
  7. [SOLVED] Lookup file with relative pathname
    By Hall in forum Excel General
    Replies: 3
    Last Post: 11-23-2005, 04:40 PM

Tags for this Thread

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