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 Code Examples Add-in

Easily access all of the code examples found on our site.

Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.

(No installation required!)