Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Deleting Worksheets

Try this approach. Type the sheet names all in CAPS in the sub

Sub delshts()
Application.DisplayAlerts = False
For Each sh In Worksheets
Select Case UCase(sh.Name)
Case "AAA", "B B", "FS": x = 1
Case Else
End Select
'If x < 1 Then MsgBox sh.Name' testing
If x < 1 Then MsgBox sh.Delete
Next sh
Application.DisplayAlerts = True
End Sub

--
Don Guillett
SalesAid Software

"Rob" wrote in message
...
I have another question pertainiing to this particular project. By the
way,
saving the file does help (lol). At the beginning of this monly project
there are certain worksheets that need to be deleted. After all the
calculations are verified there are certain sheets that need to be
deleted.
I am using the following code at the beginning:

Sub DeleteCCWorksheets()

Dim mySht As Worksheet


Application.DisplayAlerts = False
For Each mySht In ActiveWorkbook.Worksheets
If mySht.Name < "Cost Center Template" And mySht.Name < "ytd.srv.inv"
And mySht.Name < "InvSrvTemplate" And mySht.Name < "ytd.srv.detail" And
mySht.Name < "InvSrvytdTemplate" And mySht.Name < "inv.finance" And
mySht.Name < "inv.srv.detail" And mySht.Name < "patti detail 2" And
mySht.Name < "dcd.detail" And mySht.Name < "recap" And mySht.Name <
"patti
detail" And mySht.Name < "detail by item" And mySht.Name < "invoice
detail"
Then
mySht.Delete
End If
Next mySht
Application.DisplayAlerts = True
End Sub

This code works fine.

Here is the code that is to be used at the end:

Sub DeleteNonMonth()



Application.DisplayAlerts = False
For Each mySht In ActiveWorkbook.Worksheets
If mySht.Name = "Cost Center Template" And mySht.Name = "ytd.srv.inv"
And
mySht.Name = "InvSrvTemplate" And mySht.Name = "ytd.srv.detail" And
mySht.Name = "InvSrvytdTemplate" And mySht.Name = "inv.srv.detail" And
mySht.Name = "patti detail 2" And mySht.Name = "dcd.detail" And mySht.Name
=
"patti detail" And mySht.Name = "invoice detail" Then
mySht.Delete
End If
Next mySht
Application.DisplayAlerts = True
End Sub

This code does nothing and I don't get an error message. Will someone
please help?





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 Chip Pearson Excel Programming 0 December 7th 06 06:45 PM
Deleting WorkSheets MANY Corey Excel Programming 4 July 4th 06 01:54 AM
Deleting worksheets Alan L. Wagoner Excel Programming 4 January 24th 05 03:19 PM
Deleting worksheets Oscar Excel Programming 1 July 23rd 04 04:36 AM


All times are GMT +1. The time now is 07:50 AM.

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

About Us

"It's about Microsoft Excel"