I need to erase any sheet that starts with "Report" but isn't "Report - Total", so I tried this code:
VB Code:
For a = 1 To ActiveWorkbook.Sheets.count If Left(ActiveWorkbook.Sheets(a).Name, 6) = "Report" And ActiveWorkbook.Sheets(a).Name <> "Report - Total" Then ActiveWorkbook.Sheets(a).Select ActiveWindow.SelectedSheets.Delete End If Next
When the code runs, it erases 2 of the correct sheets, but I get an error once it reaches the 3rd sheet. The error is "1 Subscript out of range" and occurs on the second line. Got any ideas?
Thanks,
Alex




Reply With Quote