VBA – Create New Workbook (Workbooks.Add)

Associated Files Download Links

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 a variable:

But, it’s better to assign the Workbook 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):

 

 

You may also like some of this related content...

Ads