H
hshayh0rn
I have some code that I thought would delete every sheet in a workbook except
the two master sheets that can't be deleted but it's not working. I'm
thinking the problem is with the OR part of the code. If I remove the OR then
the code runs but the OR is pretty important so I'm look for some insight.
Sub DeleteSheets()
Dim wks As Worksheet
Application.DisplayAlerts = False
For Each wks In Worksheets
If wks.Name <> "Product Names Data" Or "Master Product Sheet" Then
wks.Delete
Next wks
ErrorHandler:
Application.DisplayAlerts = False
End Sub
the two master sheets that can't be deleted but it's not working. I'm
thinking the problem is with the OR part of the code. If I remove the OR then
the code runs but the OR is pretty important so I'm look for some insight.
Sub DeleteSheets()
Dim wks As Worksheet
Application.DisplayAlerts = False
For Each wks In Worksheets
If wks.Name <> "Product Names Data" Or "Master Product Sheet" Then
wks.Delete
Next wks
ErrorHandler:
Application.DisplayAlerts = False
End Sub