Function Problems

Display an Excel Workbook File Name Without the Extension

Bushra ParveenBushra Parveen Dec 2, 2026 868 views

Question details

Display the current workbook file name in a cell without its path or file extension.

Display an Excel Workbook File Name Without the Extension
Product
Microsoft Excel
Device & OS
not provided
Scenario
A user wants a worksheet formula that shows the saved workbook's name without the extension.
Observed behavior
The desired cell displays only the workbook name, even when the name contains periods.
Before you start

Save the workbook using File > Save or Save As before entering the formula. CELL("filename",A1) may return an empty value until the workbook has been saved.

Solution 1Recommended

Use TEXTAFTER and TEXTBEFORE in Microsoft 365

Use this formula in a version of Excel that supports LET, TEXTAFTER, and TEXTBEFORE.

1
Save the workbook

Select File > Save and give the workbook a file name if prompted.

2
Enter the formula

Select the cell where you want the name to appear and enter =LET(f,CELL("filename",A1),n,TEXTBEFORE(TEXTAFTER(f,"["),"]"),TEXTBEFORE(n,".",-1)).

3
Check the result

Press Enter. The cell should show the workbook name without its path or final extension.

Use TEXTAFTER and TEXTBEFORE in Microsoft 365
Names with periods: The -1 argument removes the final period and the text after it, preserving earlier periods in the workbook name.
Work with workbook names in WPS Office

Display the Workbook Name in WPS Spreadsheets

Use CELL and text formulas in WPS Spreadsheets to extract a saved workbook's name and remove its extension.

  1. 1. Open the workbook: Open WPS Spreadsheets and select File > Open to choose your workbook.
  2. 2. Save the file: Select File > Save or Save As and give the workbook a file name.
  3. 3. Extract the file name: In an empty cell such as B1, enter =MID(CELL("filename",A1),FIND("[",CELL("filename",A1))+1,FIND("]",CELL("filename",A1))-FIND("[",CELL("filename",A1))-1).
  4. 4. Remove the extension: In another cell, enter =LEFT(B1,FIND(CHAR(1),SUBSTITUTE(B1,".",CHAR(1),LEN(B1)-LEN(SUBSTITUTE(B1,".",""))))-1) and press Enter.
Display a workbook name without its path or extensionPreserve periods within the workbook nameOpen and edit Microsoft Excel XLSX and XLS filesUse a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

Why is CELL("filename") blank?

The workbook may not have been saved. Select File > Save, then recalculate the formula. If needed, close and reopen the saved workbook.

Will the formula work if the workbook name contains periods?

Yes. The Microsoft 365 formula removes the text after the last period in the extracted file name. The older-version helper-cell formula also removes the final extension.

What if Excel does not recognize TEXTBEFORE or TEXTAFTER?

Your Excel version may not support those functions. Use the helper-cell formulas with MID, FIND, LEFT, and SUBSTITUTE instead.

Can I display the file name with its extension?

Yes. Use the first helper-cell formula to extract the text between the square brackets returned by CELL("filename",A1).