Answers for "excel vba delete sheets and stop excel asking the user to confirm"

VBA
4

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
Posted by: Guest on March-29-2020

Code answers related to "VBA"

Browse Popular Code Answers by Language