ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Worksheets in same excel (https://www.excelbanter.com/excel-programming/393201-delete-worksheets-same-excel.html)

Raj[_11_]

Delete Worksheets in same excel
 
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.....


Mike H

Delete Worksheets in same excel
 
Try

Application.displayalerts=false

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

Application.displayalerts=true

Mike

"Raj" wrote:

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.....



IanKR

Delete Worksheets in same excel
 
Assume that missing closing bracket is a typo?

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



Dave Peterson

Delete Worksheets in same excel
 
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
on error goto 0
application.displayalerts = true


Raj wrote:

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.....


--

Dave Peterson

Raj[_11_]

Delete Worksheets in same excel
 
On Jul 13, 9:00 am, Dave Peterson wrote:
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
on error goto 0
application.displayalerts = true

Raj wrote:

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.....


--

Dave Peterson


thanks... dave...



All times are GMT +1. The time now is 12:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com