
Use a user-defined function to copy the name
of a workbook into a cell
To determine the name of a workbook, including the path and
current worksheet name, you can type the function
=CELL("Filename") in cell A2. Another way to determine the
name is to write a user-defined function, as shown here.
4
To display the workbook name in a cell:
1. Press <Alt+F11> to open the Visual Basic Editor.
2. From the Insert menu, click Module.
3. Type the following function:
Function WkbName()
WkbName = ActiveWorkbook.Name
End Function
4. Close the VBA Editor by pressing <Alt+Q> and in cell A3
type the following function: =WkbName().
5. Press <Enter>.
User-defined Functions