Forum Discussion

himmaugh's avatar
himmaugh
Copper Contributor
Sep 21, 2022

How to add file name to excel document

was on dinosaur MS Office 2007; now on MS 365; my question is how to add the docūment file name to an excel worksheet; i remember doing this on the dinosaur so, I am assuming it can still be done; thank you

2 Replies

  • JMB17's avatar
    JMB17
    Bronze Contributor
    If you have these text functions, then you could try:

    =TEXTBEFORE(TEXTAFTER(CELL("filename"), "["), "]")
  • DexterG_III's avatar
    DexterG_III
    Iron Contributor

     

    himmaugh it sure can be.  The filename is actually inside of brackets using the Cell("Filename") function so the formula below returns the location of those brackets and pulls everything in between them.   

     

    =MID(CELL("filename"),SEARCH("[",CELL("Filename"))+1,SEARCH("]",CELL("Filename"))-SEARCH("[",CELL("Filename"))-1)

     

    Hope this helps. 

    Dexter

     

Resources