ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Text
  3. How to Get the Sheet Name in a Cell in Excel

How to Get the Sheet Name in a Cell in Excel

By ExcelReady Team·Updated November 3, 2026·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+
  1. What does CELL("filename") return?
  2. How to get the sheet name with TEXTAFTER
  3. How to get the sheet name with MID and FIND
  4. How to get the workbook name and folder path
  5. How to use the sheet name in other formulas
  6. Why is the sheet name formula blank or wrong?
  7. Practise it

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:

Excel formula
C:\Reports\[Sales 2026.xlsx]March
PartTextHow to find it
Folder pathC:\Reports\Everything before [
Workbook nameSales 2026.xlsxBetween [ and ]
Sheet nameMarchEverything 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:

Excel formula
=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:

Excel formula
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,31)

Here is how it works on C:\Reports\[Sales 2026.xlsx]March:

  1. FIND("]",...) returns 28, because ] is the 28th character.
  2. +1 moves to position 29, the first letter of the sheet name.
  3. 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 wantMicrosoft 365Any 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:

  1. The result is blank. The workbook hasn't been saved. Save it, then recalculate with F9 (Mac: F9 or ⌘=).
  2. Every sheet shows the same name. The A1 reference is missing. Use CELL("filename",A1), not CELL("filename").
  3. #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.
  4. #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.

fx
ABCD
1
CELL output
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

LessonTEXTBEFORE and TEXTAFTERSplit emails, "Last, First" names and file paths at a delimiter with TEXTBEFORE and TEXTAFTER, including picking which occurrence to split at.LessonWorksheets and cross-sheet referencesSwitch, add and rename worksheet tabs, then use other sheets in formulas: Prices!B3, a lookup against a price list tab, and a total across monthly tabs.Function guideMIDPull characters from any position with Excel's MID. Extract IDs, email domains and text between brackets with FIND. Examples and live practice.Function guideFINDLocate a character inside text with Excel's FIND, then use it with LEFT, MID and RIGHT. Case rules, #VALUE! fixes and a live exercise.

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.

Sources

  • MID, MIDB functions - Microsoft Support
  • FIND, FINDB functions - Microsoft Support
  • TEXTAFTER function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 3, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. What does CELL("filename") return?
  2. How to get the sheet name with TEXTAFTER
  3. How to get the sheet name with MID and FIND
  4. How to get the workbook name and folder path
  5. How to use the sheet name in other formulas
  6. Why is the sheet name formula blank or wrong?
  7. Practise it

Keep reading

Basics· 5 min read

How to Rename, Add and Move Sheets in Excel

To rename a sheet in Excel, double-click its tab at the bottom of the window, type the new name and press Enter. You can also right-click the tab and choose Rename. Names can be up to 31 characters and can't use symbols such as / or ?. Formulas that point to the sheet update to the new name automatically.

Lookups· 6 min read

INDIRECT Function in Excel: Build References From Text

The INDIRECT function in Excel turns a piece of text into a real cell reference. =INDIRECT("B5") returns the value in B5, and =INDIRECT("'"&A2&"'!B5") reads B5 on the sheet named in A2. It is useful for picking a sheet or range by name, but it is volatile, so it slows big workbooks and breaks silently when names change.

Text· 7 min read

TEXTBEFORE and TEXTAFTER in Excel

TEXTBEFORE returns the text before a delimiter, and TEXTAFTER returns the text after it. =TEXTBEFORE(A2,"@") gives the username of an email, and =TEXTAFTER(A2,"@") gives the domain. A third argument picks which occurrence: -1 means the last one. They need Microsoft 365, Excel for the web or Excel 2024; in older Excel, use LEFT or MID with FIND.

More on text

  • How to Add or Keep Leading Zeros in Excel
  • LEFT, RIGHT and MID in Excel: Pull Out Part of a Cell
  • Line Breaks in Excel: In a Cell and in a Formula
  • MID Function in Excel: Pull Text From the Middle
  • How to Convert a Number to Words in Excel
  • Excel REGEX Functions: REGEXTEST, REGEXEXTRACT, REGEXREPLACE
All text articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free