By Ajeet Kumar
EXCEL VBA: TO DELETE ALL SHEETS EXCEPT SHEET "SAFE" OF A WORKBOOK
Sub pDeleteSheets()
Dim Sht As Worksheet
Dim intC As Integer
On Error GoTo lblERR
Application.ScreenUpdating = False
Application.DisplayAlert = False
For intC = ThisWorkbook.Sheets.Count To 1 Step -1
ThisWorkbook.Sheets(intC).Activate
If ActiveSheet.Name <> "SAFE" Then
ActiveSheet.Delete
End If
Next
lblERR:
If Err.Number <> 0 Then
MsgBox "Error Number:" & Err.Number & vbCrLf & "Error Description: " & Err.Number
End If
Application.ScreenUpdating = True
Application.DisplayAlert = True
End Sub
Sub pDeleteSheets()
Dim Sht As Worksheet
Dim intC As Integer
On Error GoTo lblERR
Application.ScreenUpdating = False
Application.DisplayAlert = False
For intC = ThisWorkbook.Sheets.Count To 1 Step -1
ThisWorkbook.Sheets(intC).Activate
If ActiveSheet.Name <> "SAFE" Then
ActiveSheet.Delete
End If
Next
lblERR:
If Err.Number <> 0 Then
MsgBox "Error Number:" & Err.Number & vbCrLf & "Error Description: " & Err.Number
End If
Application.ScreenUpdating = True
Application.DisplayAlert = True
End Sub
No comments:
Post a Comment