Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. 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

by Allen Wyatt
(last updated February 6, 2016)

9

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).

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, and 2016. 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

Showing Text when a Cell is Empty

Wouldn't it be great if you could have Excel display some text in a cell only when that cell is empty? Unfortuantely, Excel ...

Discover More

Counting Employees in Classes

Excel is very good at counting things, even when those things need to meet specific criteria. This tip shows how you can do a ...

Discover More

Pictures inside Shapes

Filling one of Excel's drawing shapes with a picture of your choosing is a neat trick. Here's how to do it.

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Hiding and Unhiding Worksheets

Worksheets are easily accessible in a workbook, but you may not want them to be so open. You can hide worksheets so they ...

Discover More

Getting the Name of the Worksheet Into a Cell

Excel allows you to change the names assigned to the worksheets in a workbook. If you want to have those names appear in a ...

Discover More

Determining the Complexity of a Worksheet

If you have multiple worksheets that each provide different ways to arrive at the same results, you may be wondering how you ...

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 8Mpixels. 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 6 - 4?

2016-02-09 10:04:00

Maria

Micky, this worked just as I needed. Thank you very much. Thank you also, Chuck. I did try your suggestion as well, but it kept opening an explorer window.

Appreciate both your responses!!
Maria


2016-02-09 09:12:23

Michael (Micky) Avidan

@Maria,
Try to run the following macro:

Sub MakeSheetsList()
SC = Sheets.Count
Columns(1).Clear
For SH = 1 To SC
Cells(SH, 1) = Sheets(SH).Name
Next
End Sub
--------------------------
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2016)
ISRAEL


2016-02-08 14:45:02

Chuck rese

Maria,
I use a simple solution to this problem. I use the formula shown, somewhere in the sheet whose name you want. Then in the second sheet, just enter a formula that references the cell in the first sheet that has the name in it.

For example:
in sheet1, cell A1
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,31)
in sheet2, cell A1
=Sheet1!$A$1

Not particularly elegant, but it works.


2016-02-08 10:00:51

Maria

Is there a way to use this to get the names of the other sheets in the same file? I am looking for a way to list all the sheet names in the first sheet (a summary type page). Thank you.


2016-02-08 07:16:29

allen

I tried using this in a subroutine but must be doing something wrong. Can you provide an example?


2016-02-07 10:49:08

Michael (Micky) Avidan

@Jim,
My answer to your question is simple - usually users are looking for the shortest(!) formula which provides the merchandise - such as:
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,31)
(Please note that a worksheet's name cannot exceed 31 characters).
--------------------------
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2016)
ISRAEL


2016-02-06 11:01:57

Jim

@Allen - you'll always get a "#VALUE" error using a function that returns the file-path in a book that hasn't been saved - because until you save the file, there is no path (location on the disk) for excel to return.


2016-02-06 10:52:13

Jim

Why not use RIGHT instead of MID to return just the sheet name?

=RIGHT(CELL("filename"),LEN(CELL("filename"))-FIND("]",CELL("filename")))

This will return everything to the right of the "]", regardless of the length of the sheet-name.


2016-02-06 09:16:50

Allen Cody

This is a handy tip, and I'll try it in a VBA subroutine to see if it works.

I tried this in my personal.xlsb file (worksheet formula) and got a "value" error, also in a new, unsaved file "book1" with the same result. When I opened a saved *.xlsm file, it worked fine.


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.