activesheet.delete no prompt code example
Example: excel vba delete sheets and stop excel asking the user to confirm
'Use the following VBA routine to SILENTLY delete a worksheet (no
'pop-up warning dialog for the user to fiddle with):
Sub DeleteWS(ndx)
Application.DisplayAlerts = False
With ThisWorkbook
'.Worksheets(ndx).Cells.ClearContents '<--Needed for Excel 2016+
'.Save '<--Needed for Excel 2016+
.Worksheets(ndx).Delete
End With
Application.DisplayAlerts = True
End Sub
'------------------------------------------------------------------------
'Call like so:
DeleteWS "Sheet1"
'or...
DeleteWS 1