简体   繁体   中英

Excel - using the name of the file (stored in a cell) to reference values from that file

in B1 cell I have a reference to a value stored in some other Excel file:

='C:\\podatki\\Finance\\Sp\\Predloge\\[L2019-1.xlsx]List1'!$A$4

The name of the file is "L2019-1.xlsx".

I would like to use A column for list of files: A1 for the first name, A2 for the second, etc...) and I would like to have B column with references to the files in the A column.

For instance, if A1 cell is "Xfiles.xlsx" then B1 would be:

='C:\\podatki\\Finance\\Sp\\Predloge\\[Xfiles.xlsx]List1'!$A$4

Which formula should I put inside [] part of the path to always get the correct name of the file (from A column)?

Thank you.

I assume you still want to get the value from cell A4 in L2019-1.xlsx (and not just the reference string), correct? In this case, simply building up the reference string based on the file name in A1 will just give you a string, but not the value from A4 in L2019-1.xlsx . You must put your reference string into the INDIRECT function to make it work.

=INDIRECT("'C:\podatki\Finance\Sp\Predloge\["&A1&"]Sheet1'!$A$4")

Be aware that INDIRECT is a volatile function, so excessive use of it might slow down your calculation.

In order for that solution to work, the file you are referencing to ( L2019-1.xlsx ) must be open.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM