Showing posts with label Filename formula. Show all posts
Showing posts with label Filename formula. Show all posts

20170511

Filename formula

There may be times when you need to insert the name of the current workbook or worksheet in to a cell.

 =CELL("filename")

The problem with this is that it gives the complete path including drive letter and folders.

Pick the Excel Path.

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

Pick the Workbook name.

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

Pick the Worksheet name.

 =MID(CELL("filename"),FIND("]",CELL("filename"))+1,255)