How do I access the current sheet name in formula (to use in INDIRECT)

I want to create a formula that I can use on multiple sheets that will do a vlookup on the table named the same as the current sheet. How do I access the current sheet name in the formula?

The idea is to do the following formula:


but as far as I can tell there is no function that returns the name of a sheet.

I was tired when I posted the question or I would have remembered that indirect only takes an address, not a formula, and given that there’s no reason to indirect the local cell reference. The problem with the Sheet() approach is that I want it to be transparent - each sheet references a separate table. The SheetName range is exactly what I’m looking for, though the function actually becomes vlookup(a1,indirect(sheetname),2,0) - note that the SheetName range needs to be indirected to work.

Hi Jim Trigg,

the JohsSUN’s defined function is fine and simple, working with/without a sheet number, allowing reference between different sheets.

But your formula does not work, in the way how it is constructed.
INDIRECT() function it is not an evaluator for formulas, only addresses as text are right.

The formula can be:


I have replaced the defined function with a little formula, as another way to get the sheet name.

As this formula to get the sheet name has not range address, there is no problem in give it a name (in the same way as you define a name for a range), for work in any sheet.
Define a range as:
SheetName = MID(CELL(“filename”),FIND("#$",CELL(“filename”))+2,LEN(CELL(“filename”)))
The formula:

I think easier is define a name range without the sheet name in it, what can work in any sheet.
Define a range as:
DataRange = $h$1:$w$100 (e.g.)
The formula:

Sample file

It seems to me that your SHEETNAME() is

Function SheetName(Optional nSheet)
If IsMissing(nSheet) Then
	SheetName = ThisComponent.getCurrentController().getActiveSheet().getName()
	SheetName = ThisComponent.getSheets().getByIndex(nSheet-1).getName()
End Function

Good afternoon.

JohnSUN (Apr 25 '13):

Function SheetName(Optional nSheet)...
End Function

It did the trick, for me. I just had to put: =SheetName(Row()) and get what I needed;thanks.

You can use the =SHEET() function. It returns the sheet number, so you could add a sheet number column to your table and do the vlookup from it.