Results 1 to 4 of 4
  1. #1
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Worksheet.Delete without a prompt (Excel 200/2002/2003)

    I have a VBA routine that creates a temporary worksheet for storing some information. (shtTemp = wbkWorkbook.Worksheets.Add)
    When I finish my routine I need to delete the temporary worksheet, but this creates a user visible "are you sure" dialog box

    I guess I could just set my sheet to be xlVeryHidden and re-use it next time, but is there a way to delete it without the user seeing a prompt?

    StuartR

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

    Re: Worksheet.Delete without a prompt (Excel 200/2002/2003)

    Put <code>Application.DisplayAlerts = False</code> before, and <code>Application.DisplayAlerts = True</code> after the line that deletes the worksheet.

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Worksheet.Delete without a prompt (Excel 200/2002/2003)

    Thanks, why didn't I think of that.

    I guess I will also have to add <code>Application.DisplayAlerts=True</code> to my error handling / exit code, in case the delete fails!

    StuartR

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

    Re: Worksheet.Delete without a prompt (Excel 200/2002/2003)

    Yes, that's what I usually do, just like <code>Application.ScreenUpdating = True</code>.

Posting Permissions

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