another macro query - deleting a worksheet within a query

G

Guest

I've got the following code in a macro to delete a worksheet within a
spreadsheet i've devised.

Sheets("Lookup tables").Select
ActiveWindow.SelectedSheets.Delete

When run, the macro (which is part of a larger macro) requests the user to
confirm the deletion of the worksheet.

Is there a piece of code I can enter to avoid this msg box appearing. I
would like the macro to automatically delete the worksheet and not ask for
confirmation to do so.

Many thanks,

David Hawes
 
G

Guest

This should do the trick

Sub deleteit()
Application.DisplayAlerts = False

Sheets("sheet1").Select

ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top