![]() |
Deleting WorkSheets MANY
Application.DisplayAlerts = False
Worksheets("3").Delete Application.DisplayAlerts = False Worksheets("4").Delete Application.DisplayAlerts = False Worksheets("5").Delete Is there a way to adapt the above code to simply delete ALL sheets than 2 Tried WorkSheets.Delete"2" but get an error Corey.... |
Deleting WorkSheets MANY
On Tue, 4 Jul 2006, Corey wrote:
Application.DisplayAlerts = False Worksheets("3").Delete Application.DisplayAlerts = False Worksheets("4").Delete Application.DisplayAlerts = False Worksheets("5").Delete Is there a way to adapt the above code to simply delete ALL sheets than 2 Change the 20 to the most possible. Dim i as Integer Application.DisplayAlerts = False On Error Resume Next For i = 2 to 20 Worksheets(i).Delete Next i Application.DisplayAlerts = True Don <www.donwiss.com (e-mail link at home page bottom). |
Deleting WorkSheets MANY
This seems to work for me. Backup before trying.
Sub DeleteSheets() Dim i As Long On Error Resume Next Application.DisplayAlerts = False For i = 3 To Worksheets.Count Worksheets(CStr(i)).Delete Next i Application.DisplayAlerts = True End Sub "Corey" wrote: Application.DisplayAlerts = False Worksheets("3").Delete Application.DisplayAlerts = False Worksheets("4").Delete Application.DisplayAlerts = False Worksheets("5").Delete Is there a way to adapt the above code to simply delete ALL sheets than 2 Tried WorkSheets.Delete"2" but get an error Corey.... |
Deleting WorkSheets MANY
This little macro will do what you want. HTH Otto
Sub Delete3Up() Dim ws As Worksheet Application.DisplayAlerts = False For Each ws In ActiveWorkbook.Worksheets If ws.Name 2 Then ws.Delete Next ws Application.DisplayAlerts = True End Sub "Corey" wrote in message ... Application.DisplayAlerts = False Worksheets("3").Delete Application.DisplayAlerts = False Worksheets("4").Delete Application.DisplayAlerts = False Worksheets("5").Delete Is there a way to adapt the above code to simply delete ALL sheets than 2 Tried WorkSheets.Delete"2" but get an error Corey.... |
Deleting WorkSheets MANY
Thanks. Worked a treat Cheers Corey.... "JMB" wrote in message ... This seems to work for me. Backup before trying. Sub DeleteSheets() Dim i As Long On Error Resume Next Application.DisplayAlerts = False For i = 3 To Worksheets.Count Worksheets(CStr(i)).Delete Next i Application.DisplayAlerts = True End Sub "Corey" wrote: Application.DisplayAlerts = False Worksheets("3").Delete Application.DisplayAlerts = False Worksheets("4").Delete Application.DisplayAlerts = False Worksheets("5").Delete Is there a way to adapt the above code to simply delete ALL sheets than 2 Tried WorkSheets.Delete"2" but get an error Corey.... |
All times are GMT +1. The time now is 11:55 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com