Deleting a worksheet

M

Martin

I had great help with my last problem from bpeltzer.

Here is my new problem.

I now want to delete some worksheets without Excel asking me if I really
want to do it. I am using the code below:

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

I want to do this automatically without having to click on the delete
dialogue box that appears.

Any ideas?

Thanks in advance,
Martin
 
C

Chip Pearson

Place

Application.DisplayAlerts = False

prior to deleting the sheets.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
J

Jan Kronsell

Try

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

Jan
 
N

Norman Jones

Hi Martin,

Try:

Sub Tester()
Application.DisplayAlerts = False
Sheets(Array("Sheet1", "Sheet2")).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