PDA

View Full Version : Deleting worksheets with specific name ??



Cinema
04-08-2016, 04:40 AM
Hi,

does somebody know how to search specific Worksheet(s), that has the Name "Diagram1" or "Diagram2" and so on, and delete them / it if they / it exist(s).
Here is a try of my code.


Sub Makro1()

Dim s As Worksheet

For Each s In Worksheets
If s.Name Like "Diagram*" Then
s.Delete
End If
Next s

End Sub

Bob Phillips
04-08-2016, 04:53 AM
Sub Makro1()
Dim s As Worksheet

Application.DisplayAlerts = False

For Each s In ThisWorkbook.Worksheets
If s.Name Like "Diagram*" Then s.Delete
Next s

Application.DisplayAlerts = True
End Sub

Cinema
04-08-2016, 07:30 AM
Hi xld,

that works perfect. Thank you