Be the first user to complete this post

  • 0
Add to List

VBA-Excel: Create Dynamic or Run-time WorkSheets using Macro.

To Create Dynamic or Run-time WorkSheets using Macro, follow the steps mentioned below

Steps:

  • Get the Active WorkBook object
  • Add the worksheets at the run time using Add().Name() method

Get the Active WorkBook object

        Set mainWorkBook = ActiveWorkbook

Add the worksheets at the run time using Add().Name() method

        mainWorkBook.Worksheets.Add().Name = “Sheet Name”

Complete Code:

Sub DynamicWorkSheets()

   Dim mainWorkBook As Workbook

   Set mainWorkBook = ActiveWorkbook

   For i = 1 To 3

   mainWorkBook.Worksheets.Add().Name = "DynamicWS_" & i

   Next

End Sub
Dynamic WorkSheets
Dynamic WorkSheets 



Also Read:

  1. VBA-Excel: WorkBook.Save Method
  2. VBA-Excel: Create or Add Worksheets at the Run time.
  3. VBA-Excel: UsedRange
  4. How to Enable Macro in Excel
  5. VBA-Excel: Clear data from Excel Sheet(WorkSheet)
  6. WorkBooks and WorkSheets
  7. Excel-VBA : Change Passwords for all the WorkSheets in one shot
  8. Excel-VBA : Open a Excel File using Another Excel File using Browse Option.