How to add file name to excel document

Copper Contributor

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

 

@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

 

If you have these text functions, then you could try:

=TEXTBEFORE(TEXTAFTER(CELL("filename"), "["), "]")