Tag: Worksheets.Delete

  • Macro To Delete Sheets From Workbook


    To delete a sheet from the workbook without the user being prompted for confirmations, here is the code:

    Sub DeleteSheet ( ) 
          Dim SheetName As String
          ‘ deletes a sheet named SheetName in the active workbook
          Application.DisplayAlerts = False
          Sheets(SheetName).Delete
    End Sub


    Macro to delete the default sheets(remember there has to be atleast 1 sheet in the workbook, you cannot delete all.) :

    Worksheets(“Sheet1”).Delete  or Worksheets(1).Delete
    Worksheets(“Sheet2”).Delete or Worksheets(2).Delete
    Worksheets(“Sheet3”).Delete or Worksheets(3).Delete