Variable, INDIRECT function help

lojkyelo

New Member
Joined
May 9, 2016
Messages
4
I have a sheet, that pulls values from two workbooks to do a comparison. I'd like to make it more flexible, so I believe I need to use the INDIRECT function to set the filename as a varaible.

Attempts to date, in C1 a file path A:\[file.xlsx]Sheet1 in A3 =INDIRECT("'"&C1&"'!B2") and various like combinations to substring the path.

In A3 what the result should be is ='A:\[file.xlsx]Sheet1'!B2 which does behave as expected when I enter it directly.

Any help be appreciated.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
If you want in A3 to have
'A:\[file.xlsx]Sheet1'!B2

just put

="'"&C1&"'!B2"
 
Upvote 0
I want the corresponding value on the file.xslx sheet in B2 - not the literal path. Sorry, hard to describe. On the file.xlsx sheet in B2 is a string I want to use in a comparison.
 
Upvote 0
In A3

=INDIRECT("'"&C1&"'!B2")

should return the value of B2 from the file C1 points if the file in question is open.
 
Upvote 0
Good call, the file is shared and was locked. Works as desired, probably need to go the version 2.0 and write a little VBA to open the file and set the file path now... Thanks!
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top