How to get current workbook name in Excel?
While using Microsoft Excel, you may require to get the workbook name for some purpose and insert the file name into a cell. In this article, we are going to show you methods of getting current workbook name in Excel with details.
Excel Productivity Tools
Office Tab: Bring powerful tabs to Office (include Excel), just like Chrome, Safari, Firefox and Internet Explorer. Save you half the time, and reduce thousands of mouse clicks for you. 30-day Unlimited Free Trial
Kutools for Excel: Save 70% of your time and solve 80% Excel problems for you. 300+ advanced features designed for 1500+ work scenario, make Excel much easy and increase productivity immediately. 60-day Unlimited Free Trial
You can get current workbook name with the User-defined function as follows.
1. Press Alt + F11 keys simultaneously to open the Microsoft Visual Basic Application window.
2. In the Microsoft Visual Basic Application window, click Insert > Module.
3. Copy following code into the Module window.
VBA code: Get workbook name
Function GetBook() As String GetBook = ActiveWorkbook.Name End Function
4. Press Alt + Q keys to close the Microsoft Visual Basic Application window and return to the workbook.
5. Select a blank cell, type =GetBook() into the cell, then press the Enter key. You can see the workbook name is populated on the selected cell.
With the Insert Workbook Information utility of Kutools for Excel, you can easily get the workbook name by inserting the workbook name into selected cell, page header or footer. Please do as follows.
|Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days.|
1. Click Enterprise > Workbook > Insert Workbook Information. See screenshot:
2. In the Insert Workbook Information dialog box, select Workbook name option in the Information section, and select the Range option to select a cell where you want to put the result in the Insert at section, and then click the OK button. See screenshot:
Now the workbook name is inserted into the selected cell immediately.
Note: You can also insert the workbook name into the header or footer as you need.