Forum Discussion

Alireza2291's avatar
Alireza2291
Copper Contributor
Apr 01, 2022
Solved

File Name

Hi There,

What kind of formula should I use to have the excel file name in a cell WITHOUT the extension of the file,

Thanks,

Ali

  • Alireza2291  Perhaps this:

     

    =MID(CELL("filename"),FIND("[",CELL("filename"))+1,FIND(".xlsx",CELL("filename"))-FIND("[",CELL("filename"))-1)

     

    It assumes that the extension you seek is ".xlsx" since you are working in an Excel file. If you are on a recent version you can avoid the receptive references to CELL() by using the LET function. 

7 Replies

  • Vimal_Gaur's avatar
    Vimal_Gaur
    Brass Contributor

    Alireza2291 If you need only file name in a cell WITHOUT the extension & path, below is the formula

     

    =RIGHT(LEFT(CELL("filename"),(SEARCH(".",(CELL("filename"))))-1),LEN(LEFT(CELL("filename"),(SEARCH(".",(CELL("filename"))))-1))-(SEARCH("[",(LEFT(CELL("filename"),(SEARCH(".",(CELL("filename"))))-1)))))

     

    paste the above formula in any cell

    save the workbook with any name and close it

    open it and you will see the file name without extension

    attached are sample files, save them on your computer & open it you will see the result

    • Riny_van_Eekelen's avatar
      Riny_van_Eekelen
      Platinum Contributor

      Alireza2291  Perhaps this:

       

      =MID(CELL("filename"),FIND("[",CELL("filename"))+1,FIND(".xlsx",CELL("filename"))-FIND("[",CELL("filename"))-1)

       

      It assumes that the extension you seek is ".xlsx" since you are working in an Excel file. If you are on a recent version you can avoid the receptive references to CELL() by using the LET function. 

  • mathetes's avatar
    mathetes
    Silver Contributor
    I think you need to provide a little more information here. For example, where is file name coming from? Do you have a whole column of file names, including their extensions, and just want to strip off the extensions? And so forth. The answer to your question is probably fairly easily--Excel can readily do text manipulation--but it would help if you could provide a bit more info on the circumstances in which you want to remove the extension(s).

Resources