View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Todd Huttenstine[_3_] Todd Huttenstine[_3_] is offline
external usenet poster
 
Posts: 68
Default 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