Written by Allen Wyatt (last updated May 22, 2021)
This tip applies to Excel 97, 2000, 2002, and 2003
Jon wonders if there is a function equivalent to =ROW() or =COLUMN() for worksheets. He needs to reference (for example) the fourth sheet in a workbook, but he can't be sure of the worksheet's name.
There are a couple of ways to approach this problem, depending on what you need to do. If you are working with a worksheet that has already been saved, then the following formula will provide you with the worksheet name for Sheet4:
=MID(CELL("filename",Sheet4!A1),FIND("]",CELL( "filename",Sheet4!A1))+1,LEN(CELL("filename", Sheet4!A1)))
You should note that there are couple of assumptions in this formula. First (and most importantly) it assumes that you know the initial name of the worksheet. In this case, the initial name is Sheet4. After the formula is in place, subsequent changes to the worksheet name will be reflected automatically in the formula. The second assumption is that the workbook you are working in has been saved. If it hasn't, then the formula returns an error until the workbook is saved and recalculated.
A different approach is to use a user-defined function. In VBA's object model, all the worksheets in a workbook are contained within the Sheets collection. These are, in turn, indexed. Thus, you can pass an index value to the function and get back the name of the worksheet at the collection's index number.
Function TabName(snum As Long) As String If snum > 0 And snum <= Sheets.Count Then TabName = Sheets(snum).Name End If End Function
For instance, if you wanted to know the name of the fourth worksheet in the collection, you could use the following in your worksheet:
=TabName(4)
The function will work just fine, even in a workbook that has not been saved. It also returns the proper worksheet name even if the worksheets are renamed or moved around.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7607) 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: Referencing a Worksheet Name.
Best-Selling VBA Tutorial for Beginners Take your Excel knowledge to the next level. With a little background in VBA programming, you can go well beyond basic spreadsheets and functions. Use macros to reduce errors, save time, and integrate with other Microsoft applications. Fully updated for the latest version of Office 365. Check out Microsoft 365 Excel VBA Programming For Dummies today!
When you add a new worksheet to a workbook, it receives a meaningful name such as "Sheet4" or "Sheet17." If you want to ...
Discover MoreIf you need to save your Excel data at different benchmarks, you might want to use some sort of "versioning" system. Such ...
Discover MoreGot a workbook with a lot of worksheets in it? Here's some handy ways to jump to the worksheet you want, alphabetically.
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
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 © 2025 Sharon Parq Associates, Inc.
Comments