Get an Excel Workbook File Name Without Its Extension
Question details
Extract the current workbook’s file name without its extension using an Excel formula.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A user wants to display the saved workbook’s name in a worksheet without its path or file extension.
- Observed behavior
- The desired result is the workbook name alone, even when the name contains additional periods.
Save the workbook first, because CELL("filename") needs a saved file to return its path and name. Choose two empty cells for the workbook name and the final result.
Extract the Workbook Name and Remove Its Extension
Use two formulas to extract the name and remove the final extension, including when the name contains periods.
Select File > Save or press Ctrl+S, and give the workbook a file name if prompted.
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). This returns the workbook name with its extension.
In another empty cell, enter =LEFT(B1,FIND(CHAR(1),SUBSTITUTE(B1,".",CHAR(1),LEN(B1)-LEN(SUBSTITUTE(B1,".",""))))-1). Replace B1 with the cell containing the extracted name if necessary.

Remove the Extension with TEXTBEFORE in Microsoft 365
Use a shorter second formula if your Excel version supports TEXTBEFORE.
Extract a Workbook Name in WPS Spreadsheet
Use CELL and text formulas in WPS Spreadsheet to display a saved workbook’s name without its extension.
- 1. Open the workbook: Open your spreadsheet in WPS Spreadsheet and select File > Save to ensure it has a saved file name.
- 2. Extract the full name: Select an empty cell such as B1 and enter =MID(CELL("filename",A1),FIND("[",CELL("filename",A1))+1,FIND("]",CELL("filename",A1))-FIND("[",CELL("filename",A1))-1).
- 3. Remove the extension: In another empty cell, enter =LEFT(B1,FIND(CHAR(1),SUBSTITUTE(B1,".",CHAR(1),LEN(B1)-LEN(SUBSTITUTE(B1,".",""))))-1).
- 4. Save the result: Select File > Save to keep the formulas in the workbook.

Frequently Asked Questions
Why does CELL("filename") return an empty value?
The workbook must be saved before CELL can return its path and file name. Select File > Save, then recalculate the worksheet if needed.
Does the MID formula remove the file extension?
No. It extracts the text between the workbook brackets, which includes the extension. Use the second formula or TEXTBEFORE to remove it.
What if the workbook name contains more than one period?
Use =TEXTBEFORE(B1,".",-1) in a supported Microsoft 365 version, or use the LEFT and SUBSTITUTE formula above. Both remove only the final extension.
Why does Excel show #NAME? for TEXTBEFORE?
Your Excel version may not support TEXTBEFORE. Use the LEFT and SUBSTITUTE formula in the recommended solution instead.




