View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
flummi
 
Posts: n/a
Default substitute the filename in a cell reference with a string in another cell.

Thanks Kostis,

for investigating this. Hope I don't take too much of your time.

What I did is this:

I loaded the workbook "example.xls
Then I created a new workbook
In this new workbook I created a simple cell reference to a cell in
example.xls
Then I closed example.xls
That gave me the full path in my reference in the new workbook.
Then I copied the filename "example.xls" from the above reference into
cell A1 in my new workbook
Then I copied the formula into another cell and modified it as you
suggested (indirect(....)
That gave me the #REF whilst the old formula still delivered the
correct result.

Here's a "screenshot"

Example.xls

904 #REF!

='C:\[Example.xls]Expenses'!$G$12 <-- formula that delivers 904
=INDIRECT("'c:\["&A1&"]Expenses'!$G$12") <-- formula that delivers
#REF
'c:\[Example.xls]Expenses'!$G$12 <-- this is what I get when I strip
off the indirect() function from the previous command

Hans