News, tips, advice, support for Windows, Office, PCs & more. Tech help. No bull. We're community supported by donations from our Plus Members, and proud of it
Home icon Home icon Home icon Email icon RSS icon
  • Delete Worksheet without Prompt?

    Posted on WSdcardno Comment on the AskWoody Lounge
    Viewing 1 reply thread
    • Author
      Posts
      • #351506 Reply
        WSdcardno
        AskWoody Lounger

        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?

      • #508702 Reply
        WScri
        AskWoody Lounger

        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 Reply
          WSdcardno
          AskWoody Lounger

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

    Viewing 1 reply thread

    Please follow the -Lounge Rules- no personal attacks, no swearing, and politics/religion are relegated to the Rants forum.

    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.