teach you to use cell data as an Excel workbook name

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.