Sunday, October 31, 2010

How to Find the Excel File Name using Excel Formulas

The formula =CELL("Filename") returns the full path of the file and includes also the file's and the sheet's name.

If you need the file name only use this formula:


=MID(CELL("filename"),FIND("[",CELL("filename"))+1,LEN(CELL("filename"))-FIND("[",CELL("filename"))-(LEN(CELL("filename"))-FIND("]",CELL("filename")))-1)
 
For example, the formula returns the file name: MyFileName.xls from the full path:
C:\My Documents\Mt Excel Samples\[MyFileName.xls]sheet1

No comments:

Post a Comment

Enter your comment here