SHEETNAME

=SHEETNAME(reference)

reference
Required. The cell reference to return the parent sheet name.

SHEETNAME returns the parent worksheet name of the reference cell.

smozgur

BatCoder
Joined
Feb 28, 2002
Messages
2,656
SHEETNAME function returns the parent worksheet name of the reference cell.

Excel Formula:
=LAMBDA(reference,
    LET(name, CELL("filename",reference),
        RIGHT(name, LEN(name) - FIND("]", name))
    )
)
Sample.xlsm
AB
1Current worksheetOther worksheet
2Sheet1Sheet2
Sheet1
Cell Formulas
RangeFormula
A2A2=SHEETNAME(A1)
B2B2=SHEETNAME(Sheet2!A1)
 
Upvote 1
Does anyone have a lambda that can provide a list of all sheetnames (without the usual VBA route)? I'm stumped on this one.
 
Does anyone have a lambda that can provide a list of all sheetnames (without the usual VBA route)? I'm stumped on this one.
Not really. I have a Named Formula / Function that can retrieve all sheet names in a single spilled columnar array:
Excel Formula:
=REPLACE(GET.WORKBOOK(1),1,FIND("]",GET.WORKBOOK(1)),"")&T(NOW())
The REPLACE portion of that formula gets rid of the Workbook name. The T(NOW()) forces it to refresh, otherwise you have to force a refresh to get new/renamed sheets. Just wrap it in TRANSPOSE to get the sheets in a list.

As for the Macro part, GET.WORKBOOK(1) is an old Macro 4 function that's still in Excel. If you use this in a new file, Excel (365) will automatically save it as a Macro Enable Workbook (.xlsm). Obviously if you incorporate it into an existing Workbook, it will have to be Saved As a Macro Enabled Workbook.

When I first started working with this, Excel was blocking the functionality. I found the fix to it on the Microsoft site and posted it here.
 

Forum statistics

Threads
1,223,575
Messages
6,173,148
Members
452,503
Latest member
AM74

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