Delete Worksheets in same excel

R

Raj

Hi all,

I am deleting some sheets of my excel worrk book after doing
certain manipulations... I'm using the followin code to delete the
sheets...


Sheets(Array("Sheet 1", "Sheet 2").Select
ActiveWindow.SelectedSheets.Delete

but when this command gets executed it ask the excel message asking
for confirmation on deleting the sheets from the workbook... is there
any way that i can delete the sheets withou asking for the
confirmation to delete nstead delete at an instance.....
 
M

Mike H

Try

Application.displayalerts=false

Sheets(Array("Sheet 1", "Sheet 2").Select
ActiveWindow.SelectedSheets.Delete

Application.displayalerts=true

Mike
 
I

IanKR

Assume that missing closing bracket is a typo?

Sheets(Array("Sheet 1", "Sheet 2")).Select
....
 
D

Dave Peterson

In case sheet 1 or sheet 2 doesn't exist, you may want to use multiple lines:

application.displayalerts = false
on error resume next
sheets("sheet 1").delete
sheets("sheet 2").delete
 
R

Raj

In case sheet 1 or sheet 2 doesn't exist, you may want to use multiple lines:

application.displayalerts = false
on error resume next
sheets("sheet 1").delete
sheets("sheet 2").delete

thanks... dave...
 

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