Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting worksheets David Excel Discussion (Misc queries) 2 January 19th 07 08:19 PM
deleting worksheets from workbook when option not available Rita318 Excel Worksheet Functions 3 January 4th 07 07:17 PM
Deleting blank worksheets Lvenom Excel Worksheet Functions 3 June 15th 06 12:28 AM
Help deleting worksheets Wilhelmutt Excel Discussion (Misc queries) 2 April 19th 05 03:23 AM
merging different worksheets in a workbook to one sheet a.pontes Excel Worksheet Functions 1 March 1st 05 06:02 AM


All times are GMT +1. The time now is 09:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"