Remove file extension from file name returned by formula

ozbeachbum

Board Regular
Joined
Jun 3, 2015
Messages
211
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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
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,221,526
Messages
6,160,341
Members
451,638
Latest member
MyFlower

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