Forum Discussion
DFClark
Apr 13, 2022Copper Contributor
How to access the file name in Excel 365
In Excel the name of the current spreadsheet file can be obtained using the CELL function with the info-type set to "filename". In Excel 365 this is not supported ("Note: This value is not supported...
Guy_Boswell
Oct 20, 2022Brass Contributor
I wish I knew!
- peterrosenbergSep 14, 2023Copper ContributorAnd if you only want your workbook filename (minus Path), you can use this trick:
=TEXTBEFORE(TAKE(TEXTSPLIT(CELL("filename");"/";-1);;-1);"]")
Provided you have the Excel 365 functions added Spring 2023 (DROP, TAKE, TEXTSPLIT).- Jay-likes-lasersApr 30, 2024Copper Contributor
peterrosenberg Using this solution, it returns me a filename which unfortunately starts with an additional "[" character. I tried using
=TEXTAFTER("[",TEXTBEFORE(TAKE(TEXTSPLIT(CELL("filename"),"/",-1),,-1),"]"))
but this returns #N/A.
I did a quick workaround, by using RIGHT() and LEN()-1; giving the desired result:
=RIGHT(TEXTBEFORE(TAKE(TEXTSPLIT(CELL("filename"),"/",-1),,-1),"]"),LEN(TEXTBEFORE(TAKE(TEXTSPLIT(CELL("filename"),"/",-1),,-1),"]"))-1)