Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting every sheet in workbook after Worksheets(4)
Hey guys,
What is the code to delete every sheet in the active workbook from worksheets(4) onward? I want to keep sheets 1-4 but delete the rest. Thanx Todd Huttenstine |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting every sheet in workbook after Worksheets(4)
Hi Todd
Something like Sub macro1() Dim totalsheets As Integer 'Application.DisplayAlerts = False 'uncomment this line to delete without prompting - don't forget to set to true once done! totalsheets = ActiveWorkbook.Sheets.Count While (5 <= totalsheets) ActiveWorkbook.Sheets(5).Delete totalsheets = totalsheets - 1 Wend End Sub should do you (prompting to delete each sheet first) - make a backup of your file before testing this one! Regards David "Todd Huttenstine" wrote in message ... Hey guys, What is the code to delete every sheet in the active workbook from worksheets(4) onward? I want to keep sheets 1-4 but delete the rest. Thanx Todd Huttenstine |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting every sheet in workbook after Worksheets(4)
Thank you
Todd "David Coleman" wrote in message ... Hi Todd Something like Sub macro1() Dim totalsheets As Integer 'Application.DisplayAlerts = False 'uncomment this line to delete without prompting - don't forget to set to true once done! totalsheets = ActiveWorkbook.Sheets.Count While (5 <= totalsheets) ActiveWorkbook.Sheets(5).Delete totalsheets = totalsheets - 1 Wend End Sub should do you (prompting to delete each sheet first) - make a backup of your file before testing this one! Regards David "Todd Huttenstine" wrote in message ... Hey guys, What is the code to delete every sheet in the active workbook from worksheets(4) onward? I want to keep sheets 1-4 but delete the rest. Thanx Todd Huttenstine |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Deleting worksheets | Excel Discussion (Misc queries) | |||
deleting worksheets from workbook when option not available | Excel Worksheet Functions | |||
Deleting blank worksheets | Excel Worksheet Functions | |||
Help deleting worksheets | Excel Discussion (Misc queries) | |||
merging different worksheets in a workbook to one sheet | Excel Worksheet Functions |