Display workbook name

To display the workbook name in a cell we can use two different Excel methods formulas or use VBA

Example: Display workbook name

Display workbook name

METHOD 1. Display workbook name

EXCEL

=MID(CELL("filename",A1),FIND("[",CELL("filename",A1))+1,FIND("]", CELL("filename",A1))-FIND("[",CELL("filename",A1))-1)
This formula returns the name of the workbook in which the formula is written. In this example the formula is written in the workbook named Exceldome.

METHOD 2. Display workbook name

EXCEL

=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1, SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-1)
This formula achieves the same outcome as the formula above, which return the name of the workbook in which the formula is written. In this example the formula is written in the workbook named Exceldome.

METHOD 1. Display workbook name

VBA

Sub Display_workbook_name()
'display the name of the workbook
ActiveSheet.Range("C4") = ActiveWorkbook.Name

End Sub

ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("C4") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.

Explanation about the formula used to display a workbook name

EXPLANATION

EXPLANATION
To display the workbook name in a cell we can use two different Excel methods formulas or use VBA.
FORMULAS
=MID(CELL("filename",A1),FIND("[",CELL("filename",A1))+1,FIND("]", CELL("filename",A1))-FIND("[",CELL("filename",A1))-1)
=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1, SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-1)

ARGUMENTS
A1: A1 is the cell reference, to cell (A1), of the the sheet where the formula is written.