简体   繁体   中英

Importing data from a different spreadsheet

I'm familiar with using the following to pull data in from another spreadsheet....

=[filename.xlsm]Sheet!A1

My question is, can I specify the filename in a cell (like AI) then use that cell reference in order to pull that data in...

A1 = filename.xlsm

Then the corresponding cell formula would be

=[AI]Sheet!A1

Such that if I changed the name of the file in cell A1 I would change the reference and pull data from another source? The above is just an example, it doesn't work so my question is can this be done and if so, how?

** The file that I am pulling data from may not be open at the same time **

Many thanks.

Yep! Using Indirect() you can:

If A1 has a filename, in B1 you can put: =Indirect("'["&A1&"]Sheet1'!A1")

Note: With Indirect() , your workbook that you're referring to has to be open, otherwise you'll see an #REF error.

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