Return to VBA Code Examples

VBA – Create New Workbook (Workbooks.Add)

This tutorial will demonstrate different methods to create a new workbook using VBA.

Create New Workbook

To create a new workbook simply use Workbooks.Add:

The newly added Workbook is now the ActiveWorkbook.

You can see this using this code:

Create New Workbook & Assign to Object

You can use the ActiveWorkbook object to refer to the new Workbook. Using this, you can assign the new Workbook to an Object Variable:

But, it’s better / easier to assign the Workbook immediately to a variable when the Workbook is created:

Now you can reference the new Workbook by it’s variable name.

Create New Workbook & Save

You can also create a new Workbook and immediately save it:

This will save the Workbook as an .xlsx file to your default folder (ex. My Documents).  Instead, you can customize the SaveAs with our guide to saving Workbooks.

Now you can refer to the Workbook by it’s name:

This code will Activate “NewWB.xlsx”.

Create New Workbook & Add Sheets

After creating a Workbook you can edit it. Here is just one example to add two sheets to the new Workbook (assuming it’s the ActiveWorkbook):


VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as

Learn More!