Forum Discussion

DFClark's avatar
DFClark
Copper Contributor
Apr 13, 2022

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 in Excel for the web, Excel Mobile, and Excel Starter.").  How can a spreadsheet determine its file name in Excel 365 (aka Excel for the web)?

5 Replies

  • GLComputing's avatar
    GLComputing
    Copper Contributor
    I've been struggling with this and MS has still not addressed it
    • peterrosenberg's avatar
      peterrosenberg
      Copper Contributor
      And 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-lasers's avatar
        Jay-likes-lasers
        Copper 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)

Resources