Insert 'n' number of worksheets in Active workbook



Code:

Sub InsertBlankSheets()
    On Error Resume Next

    Dim N As Integer
    N = InputBox("Please enter the number of Blank Sheets to be inserted.", "Insert Worksheet(s)", 1)
    For i = 1 To N
'Sheets.count returns the number of sheets present in the workbook
'So every sheet will be added after the last sheet
        ActiveWorkbook.Sheets.Add after:=Sheets(Sheets.Count)
    Next

    On Error GoTo 0
End Sub


Note: If you want to add sheets before the first sheet, change the line inside For Loop to following:
        ActiveWorkbook.Sheets.Add before:=Sheets(1)



Comments