VBA Create New Workbook with Name

Create Workbook with Name in Excel VBA. Where Workbook represents an object. It is part of workbooks collection. Add is a method to create new workbook in Excel VBA. When we create new workbook default name of workbook is Book1, Book2, … BookN. Where N represents the next available number.

Syntax to Create New Workbook

Here is the following syntax to create new Workbook.

Workbooks.Add

Macro to Create New Workbook with Name in Excel VBA

Here is the following example Macro to Create New Workbook with Name in Excel VBA.

'VBA Create New Workbook with Name in Excel
Sub VBA_Create_New_Workbook_With_Name()
    
    'Create New Workbook
    Workbooks.Add
    
    'Save Above Created New Workbook
    ActiveWorkbbok.SaveAs Filename:="D:\VBAF1\Test.xlsx"
    
End Sub

VBA Code to Create New Workbook with Name

Let us see the following example Macro to Create New Workbook with Name and assigned to an object in Excel VBA.

'VBA Create New Workbook with Name in Excel
Sub VBA_Create_New_Workbook_With_Name_Ex2()
    
    'Variable declaration
    Dim sWorkbook As Workbook
    
    'Create New Workbook
    Set sWorkbook = Workbooks.Add
    
    'Save Above Created New Workbook
    sWorkbook.SaveAs Filename:="D:\VBAF1\Test.xlsx"
    
End Sub

Instructions to use Macro

Here are the instructions to use above macro procedure in Visual basic editor.

  • Open Visual Basic Editor(VBE) by clicking Alt +F11
  • Go to code window by clicking F7
  • Copy above specified macro or procedure
  • Paste above copied code in code window
  • Run macro by clicking F5 or Run command
  • You can see output on the screen
  • Find above output screenshot of the specified procedure.

Related Workbook Object articles

You may also like the related Workbook Object articles.

VBA Workbook Object






1 thought on “VBA Create New Workbook with Name in Excel”

  1. firtukloimutrzas

    Thanx for the effort, keep up the good work Great work, I am going to start a small Blog Engine course work using your site I hope you enjoy blogging with the popular BlogEngine.net.Thethoughts you express are really awesome. Hope you will right some more posts.

Leave a Comment

Your email address will not be published. Required fields are marked *