Watch the video to see how the macro is implemented. Also, the code is
given below for your reference.
- Click on Tools in the menu bar. From the Macro option
select Visual Basic.
- In the Visual Basic Editor menu bar click on insert
and then Module.
- First define a macro name like AddNew()
- We then assign it to an object variable called NewBook
- In our example, the
Excel Workbook object returned by the Add method is
assigned to the
object variable, NewBook.
- Next, several properties of NewBook are set using the
Inside the block you can easily control the new Excel workbook
properties using the object
- The 'SaveAs' part of the code will save the file in
default folder mostly MyDocuments and you can see the filename in the
title bar of the workbook when you run the macr.
Set NewBook = Workbooks.Add
.Title = "Employee Details"
.Subject = "Employees"