Forum Discussion
Excel cell reference to sheet number
I think the sheet code name is only available within VBA. It is possible to access the sheet name using
= CELL("directory")
but I think a better option would be to use defined names or Table names in preference to direct cell references.
- Bernd13505Jan 26, 2022Copper Contributor
PeterBartholomew1 Hi Peter, thanks a lot for your answer.
The function =CELL("directory"...) is well known to me - it makes it easy to extract the "given name" of a worksheet and the "path" of a workbook.
But that's not what I need. In principle, I need a kind of reverse function of =SHEET().
=SHEET() gives back the actual position of a sheet in the workbook.
I want to address a certain cell in a worksheet which is at a certain position in the workbook.
Example: if cell A1 of the second worksheet contains the function =SHEET(), the cell value is 2.
If I would move that second worksheet on another position in the workbook, let's say the third position, then that cell A1 with the function =SHEET() would give back the cell value 3.
My wish is as follows (example):
In cell A1 of the first worksheet I would type in a function which addresses for example the cell A1 in the second worksheet, the second worksheet is named "Sheet-2" by myself as its "given name". As long as I use the reference =Sheet-2!A1, I would easily get the value of that cell. And I could move that "Sheet-2" to another position (for example third position) in the workbook and would still get the same value with the same reference =Sheet-2!A1. But that's not what I want: my cell reference in the first sheet shall instead give me the value of cell A1 in the second sheet.
I search the syntax how to use the worksheet number (=the position of the worksheet in the workbook) in a cell reference.