Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Delete Multiple Worksheets

Good Morning
I have a workbook which uses a loop funtion in a macro to
collect data for a monthly history report. Sheets are created for every day
of the month, then a final summary sheet with the totals for all days. How
do I create a macro to delete all the sheets which were created for every
day of the month, but keep the summary sheet. Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Delete Multiple Worksheets


Application.DisplayAlerts = False
For Each sh In ActiveWorkbok.Worksheets
If sh.Name < "Summary" Then
sh.Delete
End If
Next sh
Application.DisplayAlerts = True

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"B.M.Spell" wrote in message
...
Good Morning
I have a workbook which uses a loop funtion in a macro to
collect data for a monthly history report. Sheets are created for every

day
of the month, then a final summary sheet with the totals for all days.

How
do I create a macro to delete all the sheets which were created for every
day of the month, but keep the summary sheet. Thanks




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete Multiple Worksheets

Try this one

Sub test()
Dim sh As Worksheet
Application.DisplayAlerts = False
For Each sh In ThisWorkbook.Worksheets
If LCase(Trim(sh.Name)) < "summary" Then
sh.Delete
End If
Next sh
Application.DisplayAlerts = True
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"B.M.Spell" wrote in message ...
Good Morning
I have a workbook which uses a loop funtion in a macro to
collect data for a monthly history report. Sheets are created for every day
of the month, then a final summary sheet with the totals for all days. How
do I create a macro to delete all the sheets which were created for every
day of the month, but keep the summary sheet. Thanks




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Delete Multiple Worksheets

DIM WS as Worksheet
DIM bKeep As Boolean
Application.DisplayAlerts = False
For Each WS on Worksheets
''''test '''
If not bKeep then
WS.delete
End If
Next
Application.DisplayAlerts = True


now the test depends on you - how did you mark the
summary worksheet?
The test might be the sheet name...
bKeep = ws.Name="summary"

or a cell in th esheet with the word Summary in it
bKeep = ws.Range("A1").Value ="summary"

as its bolean, bKeep will be false by defualt unless the
test sets it to true. if true, the the ws is not deleted

atrick Molloy
Microsoft Excel MVP



-----Original Message-----
Good Morning
I have a workbook which uses a loop

funtion in a macro to
collect data for a monthly history report. Sheets are

created for every day
of the month, then a final summary sheet with the totals

for all days. How
do I create a macro to delete all the sheets which were

created for every
day of the month, but keep the summary sheet. Thanks


.

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
Delete all rows below certain value on multiple worksheets? [email protected] Excel Discussion (Misc queries) 1 January 4th 08 05:51 PM
Delete Blank Rows Code - Multiple Worksheets - Multiple Documents BenS Excel Discussion (Misc queries) 3 June 29th 07 12:20 AM
insert or delete rows across multiple worksheets? BobW Excel Discussion (Misc queries) 1 February 16th 06 05:02 PM
delete rows from multiple worksheets dckrause Excel Worksheet Functions 1 June 1st 05 03:24 AM
Can you delete multiple worksheets with one command? pebel Excel Worksheet Functions 2 March 18th 05 01:58 AM


All times are GMT +1. The time now is 10:52 PM.

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"