Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delete a sheet in Excel (Excel 2000)

    Hi

    Does anybody know how to prevent the "Confirm deletion" message when trying to delete a worksheet from within a macro. I do not want to say ok load of times while my macro is deleting sheets.

    Many thanks


    Mike

  2. #2
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete a sheet in Excel (Excel 2000)

    Thanks Hans......... works fine now.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Delete a sheet in Excel (Excel 2000)

    <P ID="edit" class=small>(Edited by HansV on 03-Feb-03 09:54. Corrected a typo - I had originally written Resume ErrHandler instead of Resume ExitHandler)</P>Set Application.DisplayAlerts = False before the code that deletes worksheets, and Application.DisplayAlerts = True after it.
    You will probably want to have an error handler in your code to make sure that the latter statement is executed even if an error occurs:

    Sub DeleteSheets()
    On Error Goto ErrHandler
    Application.DisplayAlerts = False
    ' Your code goes here

    ExitHandler:
    Application.DisplayAlerts = True
    Exit Sub

    ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
    End Sub

Posting Permissions

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