No prompt before delete

I have a couple of lines of code that delete the default sheets from the workbook that my application creates.

        Dim DeadSheet As Worksheet
        DeadSheet = xlBook.Sheets("Sheet1")
        DeadSheet.Delete()
        DeadSheet = xlBook.Sheets("Sheet2")
        DeadSheet.Delete()
        DeadSheet = xlBook.Sheets("Sheet3")
        DeadSheet.Delete()

When the users run the program, they are prompted before deleting each sheet.  Is there a way to skip this prompting to speed up the process?

lgropperAsked:
Who is Participating?
 
bruintjeCommented:
Hello lgropper,

assuming you declared your xl app earlier, you can use something like
---------
xlApp.ScreenUpdating = false
xlApp.DisplayAlerts = false

        Dim DeadSheet As Worksheet
        DeadSheet = xlBook.Sheets("Sheet1")
        DeadSheet.Delete()
        DeadSheet = xlBook.Sheets("Sheet2")
        DeadSheet.Delete()
        DeadSheet = xlBook.Sheets("Sheet3")
        DeadSheet.Delete()

xlApp.DisplayAlerts = true
xlApp.ScreenUpdating = true
---------

hope this helps a bit
bruintje
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.