There are few instances when we want to store the File Name or Current Workbook Name in a particular Cell. This is very easy. This can be done by using Cell() function as shown below:
Syntax: =CELL(“filename”)
Returned Value: C:\Users\Vish\Desktop\[Test.xlsx]Sheet1
Note: The problem with this is that it gives the complete path including Drive and folders with Sheet Name.
- To Get the Path: (Only Path, Excluding File Name)
Syntax: =MID(CELL(“filename”),1,FIND(“[“,CELL(“filename”))-1)
Returned Value: C:\Users\Vish\Desktop\
- To Get the Workbook Name: (Only File Name)
Syntax: =MID(CELL(“filename”),FIND(“[“,CELL(“filename”))+1,FIND(“]”,CELL(“filename”))-FIND(“[“,CELL(“filename”))-1)
Returned Value: Test.xlsx
- To Get the WorkSheet Name:
Syntax: =MID(CELL(“filename”),FIND(“]”,CELL(“filename”))+1,255)
Returned Value: Sheet1
Read this Also:
Hi,
My friend refered this website to me, which is really very helpful for me to learn lot in excel. I am plan to learn lot through this site. Please upload all the best things of excel in future.
Thanks Prabhakar,
Keep giving your valuable feedback and suggestions…Sure i will try my best to put best articles about Excel and Excel Macro.