SOLVED

Reference a cell to grab the sheet name for another cell reference?

Copper Contributor

I want to use a cell in the current workbook to reference a cell in another workbook.  Essentially I have a lot of copies of the same formatted data and I'm trying to compile a summary. Is there a way to reference a cell instead of typing in something like "=SheetName!$L11", "SheetName" would be found from the value in another cell (ie see screenshot where Reach1 would be the sheet name).  I'm not sure how exactly to ask this question.  I'm sure I could do it in VBA but ideally want to keep it not macro-enabled. Thanks in advance!

 2021-11-16_14-24-31.jpg

7 Replies
best response confirmed by kczyzyk (Copper Contributor)
Solution

@kczyzyk 

If you mean that you want to reference a cell in another sheet in the same workbook, you can use the INDIRECT function:

 

=INDIRECT("'"&H2&"'!L11")

 

This can be filled to the right.

That's perfect, thank you!

Is it possible to do this when referencing a sheet in another workbook? @kczyzyk 

Is it possible to do this when referencing a sheet in another workbook? @kczyzyk 

@MattWaters 

You can use INDIRECT to refer to a cell in another workbook if that workbook is open in Excel.

INDIRECT does not work with closed workbooks - it will return #REF!

 

Let's say you want to refer to cell L11 on a sheet whose name is in H2 in a workbook whose name is in G2. As mentioned above, that workbook should be open.

=INDIRECT("'["&G2&"]"&H2&"'!L11")

Awesome thanks! @kczyzyk 
Is it possible to hard code the workbook name, but reference the sheet name via indirect possible?

I've tried it along the lines of:
=INDIRECT('[workbook.xls]"&H2&"'!L11)
But can only make it work if I reference both the sheet and the workbook withing the indirect function. Trying to get around it not working if the workbook is closed, as the workbook name will always remain constant.

Hope that makes sense

@MattWaters 

It won't work with a closed workbook, even if that is always the same workbook. You'll have to open it in Excel.

1 best response

Accepted Solutions
best response confirmed by kczyzyk (Copper Contributor)
Solution

@kczyzyk 

If you mean that you want to reference a cell in another sheet in the same workbook, you can use the INDIRECT function:

 

=INDIRECT("'"&H2&"'!L11")

 

This can be filled to the right.

View solution in original post