How to Add a New Workbook in VBA


Visual Basic for Applications (VBA) is a programming language designed for Microsoft Office applications. While there isn't a tool or button for every possible scenario in Excel, VBA can help you customize Microsoft Excel to fit your needs. For example, if you find yourself constantly opening new workbooks, you can replace the mouse clicks with a VBA macro, a section of executable code. Once you've written the code, you can open new workbooks with the push of a button.

Things You'll Need

  • Excel 2010 or Excel 2007
  • Press the "Alt" and "F11" keys together in your workbook to open the Visual Basic Editor (VBE).

  • Click "Insert" and then click "Module" to open a blank module window.

  • Type the following:

    Sub AddNew()

    Set NewBook = Workbooks.Add

    With NewBook

    .Title = "All Sales"

    .Subject = "Sales"

    .SaveAs Filename:="Allsales.xls"

    End With

    End Sub

  • Press "F5" to run the program and open a new workbook.

Related Searches


Promoted By Zergnet


You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!