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
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.
|
=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.
|
Sub Display_workbook_name()
'display the name of the workbook
ActiveSheet.Range("C4") = ActiveWorkbook.Name
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.
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
To display the workbook name in a cell we can use two different Excel methods formulas or use VBA.
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)
=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.