Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Good afternoon everyone.
I have yet another problem that is doing my head in. I am trying to programmatically delete all worksheets in a workbook except the first one. I have tried the following: Dim p As Integer Dim q As Integer p = Worksheets.Count If p = 2 Then For q = 2 To p Worksheets(q).Delete Next q End If This however gives me a 'Subscript out of range' if there are more than 2 sheets in the workbook The Debugger tells me that there is something wrong with: Worksheets(q).Delete Hope this is enough information. Thanks in advance for any help. KJ |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Deleting worksheets in a macro | Excel Worksheet Functions | |||
Deleting worksheets | Excel Discussion (Misc queries) | |||
Help deleting worksheets | Excel Discussion (Misc queries) | |||
Deleting worksheets | Excel Programming | |||
Deleting worksheets | Excel Programming |