Be the first user to complete this post

  • 0
Add to List

VBA-Excel: Create a WorkBook at Runtime.

Using VBA (Visual Basic for Applications) , you can create Excel workbook at the runtime by using Add() method.

If you won’t provide any name for the workbook it will be created as BookN, where N will increase automatically, starting from 0, as you call WorkBook.Add() function.

Function FnCreateWorkBook()

         Dim objWorkBook As Workbook

         Set objWorkBook = Workbooks.Add

         objWorkBook.SaveAs Filename:="NewWorkBook.xls"

End Function

.Add() method creates a workbook and return object of the that. Later on you can use that object to save it to specific location or other operations.

Also Read:

  1. VBA Excel – Looping Through a Range of Cells
  2. VBA-Excel: Copy/Paste data - Copy the data from a call and paste it to another cell
  3. VBA-Excel: Copy/Paste data - Copy the Entire data from one sheet to another
  4. VBA-Excel: Create Dynamic or Run-time WorkSheets using Macro.
  5. VBA Excel – Refer to Multiple Ranges : Union Method
  6. VBA-Excel: Modified Consolidator – Merge or Combine Multiple Excel Files Into One Where Columns Are Not In Order
  7. VBA-Excel: UsedRange
  8. Excel-VBA : Insert Multiple Images from a Folder to Excel Cells