Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: How to delete multiple sheets

  1. #1
    Board Regular
    Join Date
    Feb 2004
    Posts
    255
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default How to delete multiple sheets

    Hi,
    I need the necessity do delete a sequence of sheets in my workbook.
    If I use this code:

    With ActiveWorkbook
    If .Worksheets.Count >= 5 Then
    For n = 5 To .Worksheets.Count
    Worksheets(n).Delete
    Next n
    End If
    End With

    I receive a confirmation message box with this message:

    "Data may exist in the sheet(s) selected for deletion. To permanently delete the data, press Delete" [DELETE] [CANCEL]

    I wish to delete all sheets without receiving any message.

    Is it possible?

    Many thanks in advance for your kind support.

    Regards,

    Giovanni

  2. #2
    MrExcel MVP VoG's Avatar
    Join Date
    Jun 2002
    Location
    127.0.0.1
    Posts
    63,651
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)

    Default Re: How to delete multiple sheets

    Try

    Code:
    For n = .Worksheets.Count To 5 Step -1
        Application.DisplayAlerts = False
        Worksheets(n).Delete
        Application.DisplayAlerts = True
    Next n
    I think it is best to loop backwards when deleting sheets, similarly to deleting rows.

  3. #3
    Board Regular
    Join Date
    Feb 2004
    Posts
    255
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How to delete multiple sheets

    Thanks VoG II for your help.
    Regards,

    Giovanni

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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