In Excel, you usually use Book1, Book2 ... As the workbook name. Can excel save the document using the data in one of our selected cells as the workbook name? The answer is yes.
1, start Excel, execute the "tools → macros →visual Basic Editor" command, into the VBA edit state (Figure 1).
Figure 1 VBA editing
2, in the Project Explorer window on the left, select VBAProject (PERSONAL. XLS) "(Personal Macro Workbook) option.
3, the implementation of the "Insert → module" command, insert a module (Module 1).
4. Enter the following code into the Code editing window on the right:
Sub baocun()
lj = InputBox("请输入文档保存路径")
ActiveWorkbook.SaveAs Filename:=lj & ActiveCell.Value & ".xls"
End Sub
Exits the VBA edit state.
5. To save a workbook document later, select the cell that contains the name (see Figure 2), and then execute the tools → macros → macros command to open the Macros dialog box (Figure 3).
Figure 2 Cell
Figure 3 Macro dialog box
6, select the macro you just edited (PERSONAL. Xls!baocun), click the "Execute" button and the system pops up the dialog shown in Figure 4.
Figure 4 dialog box
7, enter the path to save the document (such as "E:office Tips"), click the "OK" button.
The document was saved successfully (see Figure 5).
Figure 5 Save success
Note: If you do not need to save the path, the document will be saved in the My Documents folder.