Can I use the content of a cell as part of filereference in other

E

Excelhobbyist

I can't believe there is not an easy way to solve the following, but thusfar,
I've not been able to find it. Your help is much appreciated:
I want to use the value of one cell to determine the filename that is used
as a reference in a different cell:
A1='\\....\[weekxx.xls]'Sheet1'!$C$15
Where xx is the value of Cell A2.
So if A2=41, then the reference is to file week41.xl and A1 will be filled
with the content of C15 in Sheet1 of that file
If A2=42, the reference is to week42.xls etc.
Anyone knows a solution that does not involve creating a macro?

Thanks in advance
 
B

barry houdini

Hello excelhobbyist,

You can try using INDIRECT function, something like

=INDIRECT("'\\....\[week"&A2&".xls]'Sheet1'!$C$15")

obviously you need to include the full path.

Note: that INDIRECT won't work with closed workbooks though. If you
want it to work with a closed workbook you could try downloading
Morefunc add-in from this link

http://www.download.com/Morefunc/3000-2077_4-10423160.html

and then use INDIRECT.EXT function
 
E

Excelhobbyist

Thanks Mike and Barry!
In fact, Barry nailed the problem best for me because he correctly suspected
that the files are indeed closed at the time I want to interrogate them. so
INDIRECT.EXT from the downlaoded library did the trick!
Thanks to both of you!

Mike H said:
Hi,

You need indirect

=INDIRECT("'[Week" & $A2 &".xls"& "]sheet1'!C15")

Mike

Excelhobbyist said:
I can't believe there is not an easy way to solve the following, but thusfar,
I've not been able to find it. Your help is much appreciated:
I want to use the value of one cell to determine the filename that is used
as a reference in a different cell:
A1='\\....\[weekxx.xls]'Sheet1'!$C$15
Where xx is the value of Cell A2.
So if A2=41, then the reference is to file week41.xl and A1 will be filled
with the content of C15 in Sheet1 of that file
If A2=42, the reference is to week42.xls etc.
Anyone knows a solution that does not involve creating a macro?

Thanks in advance
 
E

Excelhobbyist

However.... now that I'm using this....
Is there a way to make the cellreference in the INDIRECT statement (External
or not - I trust for the moment that they behave in the same manner) behave
according to the standard rules of relative references, i.e. imagine:
A1=41
B1=42
A2=INDIRECT("'\\...\[week"&A$1$".xls]Sheet1'!$Z1")

Copying A2 to A3 should give:
A3=INDIRECT("'\\...\[week"&A$1$".xls]Sheet1'!$Z2") (i.e from week 41)
While copying A2 to B2 gives:
B2=INDIRECT("'\\...\[week"&B$1$".xls]Sheet1'!$Z1") (i.e. from week 42)

Again, thanks in advance!

shifts from Z1 to Z2 if the formula is copied downwards to A3, but does not
shift to AA1 when the formula is copied to B2 ??

Mike H said:
Hi,

You need indirect

=INDIRECT("'[Week" & $A2 &".xls"& "]sheet1'!C15")

Mike

Excelhobbyist said:
I can't believe there is not an easy way to solve the following, but thusfar,
I've not been able to find it. Your help is much appreciated:
I want to use the value of one cell to determine the filename that is used
as a reference in a different cell:
A1='\\....\[weekxx.xls]'Sheet1'!$C$15
Where xx is the value of Cell A2.
So if A2=41, then the reference is to file week41.xl and A1 will be filled
with the content of C15 in Sheet1 of that file
If A2=42, the reference is to week42.xls etc.
Anyone knows a solution that does not involve creating a macro?

Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top