+ Reply to Thread
Results 1 to 7 of 7

Use a reference cell for the file name in a path

  1. #1
    Forum Contributor
    Join Date
    05-16-2012
    Location
    Latina, ITALY
    MS-Off Ver
    Excel 2010--2016
    Posts
    947

    Use a reference cell for the file name in a path

    Good evening as I would like to know if it is possible to use a cell for the reference of the name on a path of a formula.
    As an example, the formula contains this path:

    .... ($ B5; 'C: \ Users \ john \ Desktop \ New folder \ [prova.xlsx] Sheet1'! ....

    put in the A1 prova.xlsx cell and in the formula put A1 type:

    .... ($ B5; 'C: \ Users \ john \ Desktop \ New folder \
    A1] Sheet1'! ....

    in red the variation I would like to do if possible
    Thank you.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,791

    Re: Use a reference cell for the file name in a path

    You would normally do that using the INDIRECT function, but this function does not work on closed workbooks.

    An alternative that you could try is to find and download the free add-in called morefunc (do a Google search for sites where you can get it). This add-in includes a function INDIRECT.EXT, which does work on closed workbooks, and I have seen comments on here that it works in XL2010.

    Hope this helps.

    Pete

  3. #3
    Forum Contributor
    Join Date
    05-16-2012
    Location
    Latina, ITALY
    MS-Off Ver
    Excel 2010--2016
    Posts
    947

    Re: Use a reference cell for the file name in a path

    Thanks in the meantime for the answer.
    If I use the INDIRECT function with the file open,
    how do I change the formula syntax?
    Thanks again

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,791

    Re: Use a reference cell for the file name in a path

    Assume A2 contains this text to define the path:

    C: \ Users \ john \ Desktop \ New folder \

    and A1 contains the filename:

    prova.xlsx

    then if you wanted to sum the cells X1:Y7 in Sheet1 of that file then you would use this formula:

    =SUM(INDIRECT("'" & A2 & "[" & A1 &"]Sheet1'!X1:Y7"))

    It won't work if the file is closed, but if the file is open you should get your result. Note that you have to explicitly include apostophes, square brackets, even ".xlsx", if these are not present in the text values.

    Hope this helps.

    Pete

  5. #5
    Forum Contributor
    Join Date
    05-16-2012
    Location
    Latina, ITALY
    MS-Off Ver
    Excel 2010--2016
    Posts
    947

    Re: Use a reference cell for the file name in a path

    Forgive me Pete with sum is fine
    = SUM (INDIRECT ("'" & A2 & "[" & A1 & "] Sheet1'! E3: E5"))

    but, with VLOOKUP it does not work what is missing?

    = VLOOKUP (B5; (INDIRECT ("'" & A2 & "[" & A1 & "] Sheet1'! $ A $ 3: $ E $ 5; 5; 0"))

    incorrect brackets or apostrophes? I can not I can not give enter
    Last edited by Berna11; 01-18-2019 at 04:05 PM.

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,791

    Re: Use a reference cell for the file name in a path

    The INDIRECT is for the table references, so try it like this:

    = VLOOKUP (B5; INDIRECT("'" & A2 & "[" & A1 & "] Sheet1'! $ A $ 3: $ E $ 5") ; 5; 0)

    Hope this helps.

    Pete

  7. #7
    Forum Contributor
    Join Date
    05-16-2012
    Location
    Latina, ITALY
    MS-Off Ver
    Excel 2010--2016
    Posts
    947

    Re: Use a reference cell for the file name in a path

    OK perfect
    Thank you

+ 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] File Path Reference Linked Workbook Cell Values
    By Pavel001 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-30-2016, 04:38 PM
  2. [SOLVED] How to link cell reference as path to import text file
    By yogi_himalayan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-03-2014, 10:49 PM
  3. Using a cell reference as a file path to a workbook
    By SandyUK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-16-2012, 02:45 PM
  4. [Ask] Import Text file And Call reference path file with Value Range.
    By dha_indra in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2012, 11:09 PM
  5. Using file path reference in vlookup
    By mlk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-05-2010, 02:52 PM
  6. Formula with cell reference in file path
    By Dave12cd in forum Excel General
    Replies: 1
    Last Post: 08-30-2010, 07:49 AM
  7. Cell name reference is adding file path which causes errors in 2007
    By truepokefan in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-08-2009, 12:34 PM

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