R
rogge
here is my awesome code:
Option Private Module
Option Compare Binary
Option Explicit
Option Base 0
Public Const strDeleteSheet = "delSht"
Private Sub deleteSheets()
Dim xlSheet As Excel.Worksheet
Application.DisplayAlerts = False
For Each xlSheet In Application.ActiveWorkbook.Worksheets
If (xlSheet.CodeName Like strDeleteSheet & "*") Then
wkbActive.Worksheets(xlSheet.Name).Delete
End If
Next xlSheet
Application.DisplayAlerts = True
Set xlSheet = Nothing
End Sub
A not trappable error occurs: xlSheet.Name = <Automation error>. The code
does not stop processing. I know this is due to changing the items in
ActiveWorkbook.Worksheets.
This error resets globally declared variables to empty/false/etc...
Any suggestions to delete sheets without resetting global variables?
Thank you.
rogge
Option Private Module
Option Compare Binary
Option Explicit
Option Base 0
Public Const strDeleteSheet = "delSht"
Private Sub deleteSheets()
Dim xlSheet As Excel.Worksheet
Application.DisplayAlerts = False
For Each xlSheet In Application.ActiveWorkbook.Worksheets
If (xlSheet.CodeName Like strDeleteSheet & "*") Then
wkbActive.Worksheets(xlSheet.Name).Delete
End If
Next xlSheet
Application.DisplayAlerts = True
Set xlSheet = Nothing
End Sub
A not trappable error occurs: xlSheet.Name = <Automation error>. The code
does not stop processing. I know this is due to changing the items in
ActiveWorkbook.Worksheets.
This error resets globally declared variables to empty/false/etc...
Any suggestions to delete sheets without resetting global variables?
Thank you.
rogge