LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default delete all sheets except...

Hi,
I am trying to delete all sheets except 3 (one of
which "admin" has got the names of the 2 other not to
delete in cells that are named "name2" and "name2").
Here's my code but it is falling over. Any idea?
Thanks

Call UnprotectWorkbook

Dim sh As Worksheet
Application.DisplayAlerts = False
For Each sh In ThisWorkbook.Worksheets
If LCase(sh.Name) < "admin" And LCase(sh.Name)
< Range("name1").Value And LCase(sh.Name) < Range
("name2").Value Then
sh.Delete
End If
Next sh
Application.DisplayAlerts = True
 
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
macro-delete all sheets except puiuluipui Excel Discussion (Misc queries) 6 October 13th 09 05:49 AM
Delete Sheets Jahsonn Excel Programming 1 April 26th 04 01:42 PM
Delete Sheets SS[_3_] Excel Programming 2 February 5th 04 02:37 PM
Delete new sheets? ianripping[_27_] Excel Programming 1 January 17th 04 02:14 PM
select and delete sheets Locachica Excel Programming 5 December 31st 03 01:02 PM


All times are GMT +1. The time now is 10:54 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"