Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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.... |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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). |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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.... |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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.... |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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.... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Deleting worksheets | Excel Discussion (Misc queries) | |||
Deleting Worksheets in VBA | Excel Programming | |||
Help deleting worksheets | Excel Discussion (Misc queries) | |||
Deleting worksheets | Excel Programming | |||
Deleting worksheets | Excel Programming |