Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Returning a Worksheet Name.

Returning a Worksheet Name

Written by Allen Wyatt (last updated September 17, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


2

Looking for a way to put the name of your worksheet directly into a cell? Excel makes this easy through the use of the CELL function. If you include the following in a cell, Excel returns the full path of the workbook, along with the sheet name:

=CELL("filename")

For instance, if you entered this into a cell in the Sheet1 worksheet of the MyWB workbook, the information returned by Excel might be something like C:\My Documents\[MyWB.xls]Sheet1 (depending, of course, on the drive and directory in which the workbook is saved).

I should also note that if you have not saved the workbook yet, the CELL function returns a #VALUE error. This is because there is no filename to actually return until such point as you save.

To return just the worksheet name from this value, you could use the following in your cell:

=MID(CELL("filename",A1),(FIND("]",CELL("filename",A1))+1),50)

This will work for any worksheet name up to 50 characters in length. (If you routinely use different lengths, simply change the value in the formula.) Continuing the earlier example, Excel would return Sheet1 as the result.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11766) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Returning a Worksheet Name.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Jumping to the Real Last Cell

Jumping to the last cell in a worksheet should be easy, but you may not always get the results that you expect. This tip ...

Discover More

Precisely Adjusting Table Column Widths

If you want to resize the width of your table columns, you can do it using a mouse, but you can get more precise widths ...

Discover More

Functions that Can Access Closed Workbooks

When creating a workbook, you can include formulas that reference data stored in other workbooks. Some functions will ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Determining a Worksheet's Number

When you add a new worksheet to a workbook, it receives a meaningful name such as "Sheet4" or "Sheet17." If you want to ...

Discover More

Sorting Worksheets According to Region

Sorting worksheet tabs can be done by using a macro. This tip provides a macro that accomplishes this task, but it also ...

Discover More

Creating Worksheets from a List of Names

Need to create a large number of worksheets using specific names? If so, you'll love the ideas presented in this tip.

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 1 + 1?

2022-09-19 01:38:38

Michael van der Riet

A client has a very small payroll -- 3 weekly paid -- and I do the payslips on Excel. For each employee I copy the last payslip and rename that tab in the format "AA yymmdd" where AA is the employee's initials. Sometimes I forget to change the date on the payslip as well. Your tip has inspired me to do something about this.

=DATEVALUE(LET(ThisDate,RIGHT(CELL("filename"),6),TEXTJOIN("/",FALSE,RIGHT(ThisDate,2),MID(ThisDate,3,2),LEFT(ThisDate,2))))


2022-09-17 10:55:16

J. Woolley

https://excelribbon.tips.net/T011766_Returning_a_Worksheet_Name.html

My Excel Toolbox includes the following function to return information about Target (a cell or range); default Target is the formula's cell:
=NameOf([This],[Target])
The first parameter This can be "sheet" (or "worksheet"), "book" (or "workbook"), "path" (or "filepath"), "app" (or "application"), "caption" (or "titlebar"), "statusbar", "user", "organization", "printer", "computer", "?" (or "help"), or the name of an environment variable (like "TEMP"). Default value is "sheet" (or "worksheet"); with "book" (or "workbook"), the filename is returned without its path.
This function is similar to Excel's CELL and INFO functions, but perhaps more useful.
See https://sites.google.com/view/MyExcelToolbox/


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.