News, tips, advice, support for Windows, Office, PCs & more
Home icon Home icon Home icon Email icon RSS icon

We're community supported and proud of it!

  • Delete Worksheet without Prompt?

    Author
    Topic
    #351506

    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?

    Viewing 0 reply threads
    Author
    Replies
    • #508702

      Use this code snippet

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

      • #508703

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

    Viewing 0 reply threads
    Reply To: Delete Worksheet without Prompt?

    You can use BBCodes to format your content.
    Your account can't use Advanced BBCodes, they will be stripped before saving.