I run a macro that deletes worksheets. I have a repeating script that changes the name of the worksheet. The worksheet names are PDGroup1 PDGroup2, PDGroup3....etc, etc. How do I loop thru the same script but having it change the number at the end of PDGroup. Currently I have multiple scripts with the different PDGroup names.
Here is what I am currently using, but multiple times
![]()
Sub Delete_PDGroup() Dim sh As Worksheet Application.DisplayAlerts = False On Error Resume Next Set sh = ActiveWorkbook.Sheets("PDGroup1") If Err.Number <> 0 Then 'MsgBox "The sheet doesn't exist" Err.clear On Error GoTo 0 Else Sheets("PDGroup1").Activate ActiveWindow.SelectedSheets.Delete Application.DisplayAlerts = True End If
Bookmarks