Function Problems

Return an Excel Workbook File Name or Active Worksheet Name

Steven ParkerSteven Parker Nov 12, 2026 869 views

Question details

The user wants formulas that return only the current workbook file name or the active worksheet name in Excel.

Return an Excel Workbook File Name or Active Worksheet Name
Product
Microsoft Excel
Device & OS
not provided
Scenario
The user needs to extract workbook and worksheet metadata for use in cells, reports, headers, or formulas.
Observed behavior
CELL("filename") returns the full file path together with the workbook name and worksheet name after the workbook has been saved.
Before you start

Save the workbook first, because CELL("filename") does not return workbook and worksheet information for an unsaved file. Enter the formula on the worksheet whose name you want to display.

Solution 1Recommended

Use TEXTAFTER and TEXTBEFORE in Excel 365

Use this option in the Excel desktop app when TEXTAFTER and TEXTBEFORE are available.

CELL("filename") returns a string in the form C:\Folder\[Workbook.xlsx]Sheet1. The formulas below isolate the text after or between the square brackets.

1
Save the workbook

Select File > Save, then save the workbook with a file name before entering the formula.

2
Return the active worksheet name

Click the cell where you want the sheet name to appear and enter =TEXTAFTER(CELL("filename"),"]",-1). Press Enter.

3
Return the workbook file name

Click another cell and enter =TEXTBEFORE(TEXTAFTER(CELL("filename"),"["),"]"). Press Enter to return the file name without its folder path.

4
Recalculate after a rename

If you rename the workbook or worksheet and the result does not refresh, press F9 or use Formulas > Calculate Now.

Use TEXTAFTER and TEXTBEFORE in Excel 365
Excel for the web limitation: TEXTAFTER and TEXTBEFORE, or the CELL("filename") result, may not work as expected in Excel for the web. Use the desktop Excel app for this method.
Work with workbook metadata in WPS Office

Display the Current Workbook and Worksheet Name in WPS Spreadsheets

WPS Spreadsheets lets you use CELL("filename") with text formulas to show the saved workbook name or current worksheet name directly in a cell. This is useful for dynamic report labels, print layouts, and worksheet documentation.

  1. 1. Open and save the spreadsheet: Open the file in WPS Spreadsheets and select Menu > Save As or Save to ensure the workbook has a saved name.
  2. 2. Add a worksheet name formula: Select an output cell and enter =MID(CELL("filename"),FIND("]",CELL("filename"))+1,255).
  3. 3. Add a workbook name formula: Select another cell and enter =MID(CELL("filename"),FIND("[",CELL("filename"))+1,FIND("]",CELL("filename"))-FIND("[",CELL("filename"))-1).
  4. 4. Refresh the displayed metadata: After renaming the file or sheet, recalculate the workbook or reopen the file if the displayed result has not updated.
Extract the active worksheet name from CELL("filename") resultsShow the workbook file name without displaying its folder pathOpen and edit Microsoft Excel .xlsx and .xls files with format compatibilityUse a familiar spreadsheet interface for formulas, cells, and worksheet management
microsoft office alternative - wps office

Frequently Asked Questions

Why does CELL("filename") return an error or blank result?

The workbook usually has not been saved yet. Use File > Save, assign a file name, and then recalculate the formula with F9 if necessary.

How can I return only the worksheet name in Excel 365?

In a cell on the target worksheet, enter =TEXTAFTER(CELL("filename"),"]",-1). The text after the closing bracket is the active worksheet name.

How do I remove the folder path from an Excel workbook name?

Use =TEXTBEFORE(TEXTAFTER(CELL("filename"),"["),"]") in Excel 365. It returns the text between [ and ], which is the workbook file name.

Can I use these formulas in Excel for the web?

They may not work reliably in Excel for the web because CELL("filename") and related workbook metadata can have limitations there. Use the Excel desktop app when possible.

Will the formula update after I rename a worksheet?

It should update after recalculation. If the old name remains visible, press F9, choose Formulas > Calculate Now, or reopen the workbook.