Results 1 to 3 of 3

Thread: SOLVED deleting certain sheets

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2003
    Location
    Los Angeles, CA
    Posts
    49

    SOLVED deleting certain sheets

    I need to erase any sheet that starts with "Report" but isn't "Report - Total", so I tried this code:

    VB Code:
    1. For a = 1 To ActiveWorkbook.Sheets.count
    2.     If Left(ActiveWorkbook.Sheets(a).Name, 6) = "Report" And ActiveWorkbook.Sheets(a).Name <> "Report - Total" Then
    3.         ActiveWorkbook.Sheets(a).Select
    4.         ActiveWindow.SelectedSheets.Delete
    5.     End If
    6. 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
    Last edited by LodBot; Jul 21st, 2003 at 04:19 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width