Remove file extension from file name returned by formula

ozbeachbum

Board Regular
Joined
Jun 3, 2015
Messages
233
Office Version
  1. 2021
Platform
  1. Windows
Hi,
I have the following formula which returns the workbook's file name: 20 CHRONICLE trades.xlsx
LET(f,CELL("filename",A1),REPLACE(REPLACE(f,FIND("]",f),500,""),1,FIND("[",f),""))
I would like it to return the file name minus the file extension: 20 CHRONICLE trades
Cheers.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
If they're all .xlsx files, then

Excel Formula:
=LET(f,CELL("filename",A1),r,REPLACE(REPLACE(f,FIND("]",f),500,""),1,FIND("[",f),""),LEFT(r,LEN(r)-5))
 
Upvote 0
Solution
Or you could try:

=LET(f,CELL("filename"),m,FIND("[",f),n,FIND(".",f,m),MID(f,m+1,n-m-1))

(assuming you don't have any "." characters in the filename)
 
Upvote 0
Thanks Eric,
The majority are .xlsx files, however I do have some Word files also.
Would you be good enough to let me know what would be need for them.
Cheers,
Dave.
 
Upvote 0
Thanks Eric,
The majority are .xlsx files, however I do have some Word files also.
Would you be good enough to let me know what would be need for them.
Cheers,
Dave.
I'm not sure how you can use an Excel formula in a Word file? In any event, all my formula does is remove the last 5 characters of the file name, so .xlsx. But Word files end in .docx so that works too. I was more worried about older files that only have .xls on them.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,198
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top