Tom’s Tutorials For Excel: How to Show Your Workbook’s Name in a Cell
Here are a few ways to show your workbook’s name in a cell, example, YourWorkbookName.xls.
Formula (goes on one line but broken into 2 lines for browser readability)
=MID(CELL("filename",A1),FIND("[",CELL("filename",A1))+1,FIND("]",
CELL("filename",A1))-FIND("[",CELL("filename",A1))-1)
Notes:
• The workbook must be named (saved at least once) beforehand.
• The formula can be entered into any cell, including cell A1.
User Defined Function
Function NameActiveWB() As String
NameActiveWB = ActiveWorkbook.Name
End Function
Example, UDF formula entry:
=NameActiveWB()
Notes:
• Workbook does NOT need to be named or saved beforehand.
• The UDF formula can be entered into any cell.
Macro
Sub NameActiveWB()
ActiveCell.Value = ActiveWorkbook.Name
End Sub
Note
• Workbook does NOT need to be named or saved beforehand.
It might help some to see the format of data that
=CELL(“filename”,A1) returns.
From memory, i think it is
Path file sheet