Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    268
    Thanks
    0
    Thanked 1 Time in 1 Post

    Delete Worksheet without Prompt?

    I am trying to code a macro that will (among lots of other things) delete a particular worksheet. The user is not supposed to know that the sheet even exists (it is "xlveryhidden" when the workbook is first opened) but there doesn't seem to be an option or keyword for the 'delete' method like "Prompt:=False" that would prevent the "this worksheet will be permanently deleted" prompt. Since the user is not supposed to know that the sheet even exists, I cannot rely on them to give the correct response to the prompt, and it rather defeats the purpose in any event....

    Any suggestions?

  2. #2
    2 Star Lounger
    Join Date
    Dec 2000
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Worksheet without Prompt?

    Use this code snippet

    'Delete aux sheet w/o user confirmation
    Application.DisplayAlerts = False
    MyWorkbookName.Worksheets("MySheetName").Delete
    'Re-enable alerts
    Application.DisplayAlerts = True

  3. #3
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    268
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Delete Worksheet without Prompt?

    Thanks - works like a charm. I knew I had seen something like that before, but couldn't recall where (early dementia, I suspect...)

Posting Permissions

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