How to Get the Sheet Name in a Cell in Excel
By ExcelReady TeamUpdated 5 min read
The short answer
To get the sheet name in a cell, use =TEXTAFTER(CELL("filename",A1),"]") in Microsoft 365 or Excel 2024. In older versions, use =MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,31). CELL returns the file path with the sheet name after the closing bracket, and it only works once the workbook has been saved.
Key takeaways
- CELL("filename",A1) returns the path, the workbook name in square brackets, then the sheet name.
- The sheet name is everything after the ] character: TEXTAFTER in Microsoft 365, or MID with FIND in any version.
- Always include the A1 reference, or CELL may return the name of a different sheet.
- CELL returns empty text until the workbook is saved, so a new file shows a blank.
- There is no standard worksheet function that lists every sheet name in a workbook.
On this page+
To get the sheet name in a cell in Excel, you combine CELL("filename"), which returns the file path and sheet name, with a text function that keeps only the part after the closing bracket. It is handy for report titles that match the tab name, or for formulas that need to know which sheet they are on. This guide shows the formula for Microsoft 365 and for older versions, plus the workbook name and the fixes for blank or wrong results.
What does CELL("filename") return?#
CELL("filename", A1) returns one piece of text with three parts: the folder, the workbook name in square brackets, and the sheet name. For a sheet called March in a saved file, it looks like this:
C:\Reports\[Sales 2026.xlsx]March| Part | Text | How to find it |
|---|---|---|
| Folder path | C:\Reports\ | Everything before [ |
| Workbook name | Sales 2026.xlsx | Between [ and ] |
| Sheet name | March | Everything after ] |
On a Mac, the folder uses forward slashes, such as /Users/sam/Documents/. For a file saved in OneDrive or SharePoint, the folder part can be a web address starting with https://. In every case the sheet name comes after the ], so the formulas below work the same way.
Two rules matter. First, the workbook must be saved: a new, unsaved file returns empty text. Second, always include the reference (A1). Without it, CELL reports the sheet that was changed last, so every sheet can end up showing the same name. Any cell on the sheet works as the reference; A1 is just a habit.
How to get the sheet name with TEXTAFTER#
In Microsoft 365 or Excel 2024, TEXTAFTER returns the text after a delimiter, which is exactly what you need:
=TEXTAFTER(CELL("filename",A1),"]")For the example, the result is March. TEXTAFTER looks for the first ] and returns everything after it. Square brackets can't appear in sheet names, so there is no risk of cutting the name in the wrong place. The guide to TEXTBEFORE and TEXTAFTER covers the optional arguments.
How to get the sheet name with MID and FIND#
In Excel 2021 and earlier, combine MID and FIND. FIND gives the position of the ], and MID takes the text that starts one character after it:
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,31)Here is how it works on C:\Reports\[Sales 2026.xlsx]March:
FIND("]",...)returns 28, because]is the 28th character.+1moves to position 29, the first letter of the sheet name.MID(...,29,31)returns up to 31 characters from there: March.
Why 31? A sheet name can be at most 31 characters long, so 31 always captures the whole name. MID stops at the end of the text, so a shorter name is fine. The MID function guide and the FIND function guide explain each argument.
An equivalent version uses RIGHT and LEN: =RIGHT(CELL("filename",A1),LEN(CELL("filename",A1))-FIND("]",CELL("filename",A1))). It returns the same name but is longer, so most people use MID.
How to get the workbook name and folder path#
The same text holds the workbook name and folder, so a small change gives you those too:
| You want | Microsoft 365 | Any version |
|---|---|---|
| Workbook name | =TEXTBEFORE(TEXTAFTER(CELL("filename",A1),"["),"]") | =MID(CELL("filename",A1),FIND("[",CELL("filename",A1))+1,FIND("]",CELL("filename",A1))-FIND("[",CELL("filename",A1))-1) |
| Folder path | =TEXTBEFORE(CELL("filename",A1),"[") | =LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1))-1) |
For the example, these return Sales 2026.xlsx and C:\Reports\. The long MID version subtracts the two bracket positions to work out the length of the name. If you often pull text from between two characters, the guide on finding the nth occurrence of a character shows more FIND patterns.
How to use the sheet name in other formulas#
A sheet name in a cell is most useful when other formulas read it:
- Report titles:
="Sales report: "&TEXTAFTER(CELL("filename",A1),"]")gives "Sales report: March" on the March sheet. Copy the sheet and rename it April, and the title follows. - Monthly tabs with the same layout: use the name to look up that month's target from a summary table with XLOOKUP.
- Building a reference to another sheet: INDIRECT turns text into a reference, for example
=INDIRECT("'"&B1&"'!C5")reads C5 on the sheet named in B1. The single quotes handle names with spaces. See how INDIRECT works and how to reference another sheet for the details.
Keep in mind that INDIRECT and CELL recalculate often, so a workbook with thousands of them can feel slow.
Why is the sheet name formula blank or wrong?#
Most problems have one of four causes:
- The result is blank. The workbook hasn't been saved. Save it, then recalculate with F9 (Mac: F9 or ⌘=).
- Every sheet shows the same name. The A1 reference is missing. Use
CELL("filename",A1), notCELL("filename"). - #VALUE! from the MID version. FIND didn't find
], which also happens when the file is unsaved and CELL returns empty text. Wrap it in IFERROR to show a message instead. - #NAME? from the TEXTAFTER version. Your Excel doesn't have TEXTAFTER. Use MID and FIND.
The name may also look out of date right after you rename a tab. Press F9 to refresh it. The filename option of CELL isn't supported in Excel for the web, so use the desktop app for files that rely on it. For the rules on what a sheet name can contain, see how to rename sheets in Excel.
There is also a SHEET function, but it returns the sheet's position number (1, 2, 3…), not its name. And no standard function lists every sheet name at once; the older GET.WORKBOOK macro function can, through a defined name, but only in a macro-enabled file.
Practise it#
The sheet name formula is really a text-splitting task. Practise TEXTBEFORE and TEXTAFTER in a live spreadsheet to split text at a delimiter, then work with tabs and links in the worksheets and cross-sheet references lesson. The exercise on this page lets you try the MID and FIND version on a real CELL result.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
Cell A2 holds the text that CELL("filename",A1) returns for a saved workbook. In B2, extract the sheet name: use MID to take the text that starts one character after the ] found by FIND, with a length of 31.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Sheet name | |||
| 2 | C:\Reports\[Sales 2026.xlsx]March | |||
| 3 | ||||
| 4 | ||||
| 5 | ||||
| 6 |
Tip: FIND("]",A2) gives the position of the bracket. Add 1 to start just after it.
Practise this in a lesson
Frequently asked questions
What is the formula to get the sheet name in Excel?
In Microsoft 365 or Excel 2024, use =TEXTAFTER(CELL("filename",A1),"]"). In older versions, use =MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,31). Both return the name of the sheet that holds the formula.
Why does CELL("filename") return a blank?
The workbook hasn't been saved yet. CELL returns empty text for a new, unsaved file. Save it once and recalculate with F9.
Why does every sheet show the same sheet name?
The formula is missing the reference argument. =CELL("filename") without A1 reports the sheet that was changed most recently, not the sheet holding the formula. Add A1 as the second argument.
How do I get the workbook name in a cell?
Take the text between the square brackets: =TEXTBEFORE(TEXTAFTER(CELL("filename",A1),"["),"]") in Microsoft 365. It returns the file name with its extension, such as Sales 2026.xlsx.
Can Excel list all sheet names with a formula?
Not with a standard worksheet function. The older GET.WORKBOOK macro function can do it through a defined name, but the file must then be saved as a macro-enabled workbook.