Question: While deleting a Sheet from the Workbook using VBA/Macro, i get one Excel inbuilt Notification to confirm the deletion. I want to show only my own built notification to confirm the deletion. How to disable that notification in VBA.

Solution: It is very easy to disable this notification while deleting a sheet from Excel. Just we need to set .DisplayAlerts as False

Private Sub CommandButton1_Click()

'---  disable all types of Alerts from Excel like while deleting the Sheet etc.

Application.DisplayAlerts =False

'--- Now delete the particular Sheet

Worksheets("Sheet2").delete

'--- Again enable the alerts

Application.DisplayAlerts = True
End Sub

 

Note: After deleting make sure that we are again setting the .DisplayAlerts as True. Otherwise, even if we are deleting any sheet from any of the Excel Sheet in your PC, no Alert will appear. So always disable it before deleting and then again enable it back after deletion.