C create new workbook

Here is an example of how to create a new workbook in Excel using VBA:

Visual Basic Editor

  1. Open the Visual Basic Editor by pressing Alt + F11 or by navigating to Developer > Visual Basic in the ribbon.
  2. In the Visual Basic Editor, click Insert > Module to insert a new module.
  3. In the module, add the following code:
    Sub CreateNewWorkbook()
     Dim wb As Workbook
     Set wb = Workbooks.Add
     wb.SaveAs "C:\Path\To\NewWorkbook.xlsx"
    End Sub

    Explanation

Run the code

  1. Click Run > Run Sub/User Form or press F5 to run the code.
  2. The new workbook will be created and saved to the specified file path.

Note