Hi Guys,
I have a excel with the following sheets :
- Menu
- Worksheet
- Filtered
- 601 01
- 601 02
- 601 01-Duplicates
- 601 02-Duplicates
The sheets with numbers could be more and at the same time could have the same sheet but with -Duplications at the end :
Example:
- 601 01
- 601 02
- 601 03
- 601 04
- 601 05
- 601 01-Duplicates
- 601 02-Duplicates
- 601 03-Duplicates
- 601 04-Duplicates
- 601 05-Duplicates
But in this case I need to delete all the sheets with the exception of :
Menu
Worksheet
Filtered
601 01-Duplicates
601 02-Duplicates
I have this code: But I'm not able to delete the sheets I want. Could you please provide me any suggestion ?
Sub DeleteSheets1()
Dim xWs As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each xWs In Application.ActiveWorkbook.Worksheets
If xWs.Name <> "Menu" And xWs.Name <> "Worksheet" And xWs.Name <> "Filtered" And xWs.Name = "*-Duplicates " Then
xWs.Delete
End If
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Attached the excel file
Book1.xlsm
Bookmarks