vba - delete sheet without warning message

  • Hi,
    when I use the code

    Code
    Sheets("Sheet1").Select
        ActiveWindow.SelectedSheets.Delete


    I always get a warning message like "data may exist...if you want to delete, press delete button"
    How can I subside these messages and automatically delete the Sheets?


    Juergen

  • Re: vba - delete sheet without warning message


    Hello juergenkemeter,
    Try

    Code
    Application.DisplayAlerts = False
    Sheets("Sheet1").Select
    ActiveWindow.SelectedSheets.Delete


    Hope this helps


    Bill

    [FONT="Arial Black"][COLOR="blue"][SIZE="4"]Bill[/SIZE][/COLOR][/FONT]
    Tip: To avoid chasing code always use Option Explicit.

  • Re: vba - delete sheet without warning message


    juergen -please remember to use Code tags.


    You don't actually need to select the sheet to delete it

    Code
    Option Explicit
    Sub DelSht()
    Application.DisplayAlerts = False
    Sheets("Sheet1").Delete
    Application.DisplayAlerts = True
    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!