Get Filename in MS Excel

0

Get Full file name with location path

How to get filename in excel
We may need to get the sheetname or the filename of the current excel worksheet into a cell. It is fairly simple to get it.
Use the following formula

=CELL("filename",A1)

This will give the full file name. Check out the various options of the same given below.



Get Filename full

Get Full file name with location path
In any cell use the following formula

=CELL("filename",A1)

This will give the full file name along with the path.
For example :- F:\TECHIE 5\EXCEL\[Get_Filename.xls]Sheet1
In the above example “Get_Filename.xls” is the file name and “Sheet1” is the sheet name.
Get file name with full location path

Get_Sheet_name_only

Get only the sheet name
But if we would like to have only the sheet_name? Then what to do?
Well then we improvise!!
We modify the earlier formula to get the sheetname out of it as follows.

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

If we check out the above formula we see that we have searched for “]” and then extracted the sheet_name which comes immediately after that.
Get filename - only the sheet name

Many other options can be found out from excel help.
We Have shown two examples of getting the filename or sheetname.
Using the same approach we can get whatever we want out of the basic =CELL(“filename”,A1) formula.
An example excel is attached at the end of the article with the above two examples

Leave a Reply

Your email address will not be published. Required fields are marked *