Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Returning a Worksheet Name.
Written by Allen Wyatt (last updated January 3, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003
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"),(FIND("]",CELL("filename"))+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 (2146) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Returning a Worksheet Name.
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!
Your workbooks can contain many, many worksheets. Which of those worksheets are the largest, however? Here's some ideas ...
Discover MoreExcel provides ways to reference the column or row number of a cell, but it doesn't provide a built-in way to reference a ...
Discover MoreExcel makes copying worksheets (duplicating them) rather easy. However, you may want a worksheet copy that differs from ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2019-07-21 22:40:45
Thanks for the tip Allen.
A slight variation that manages any file length:
= RIGHT(CELL("filename"),LEN(CELL("filename")) - FIND("]",CELL("filename")))
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments