Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to delete unwanted sheets


Hello everyone

I want to clear a workbook of all but 3 worksheets on opening th
workbook.
Unfortunately I do not know the names of the sheets to delete -
simply want to keep "Log", "Data", Lists" - There may be as many as 1
unwanted sheets.

Could anyone suggest code to do this?

TIA

Kenny
Various combinations of
Win Me, 2000,XP
Office 97 and 200

--
N E Bod
-----------------------------------------------------------------------
N E Body's Profile: http://www.excelforum.com/member.php...fo&userid=1126
View this thread: http://www.excelforum.com/showthread.php?threadid=31868

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to delete unwanted sheets


Sub SheetDelete()

For Each sht In Worksheets

If sht.Name < "Log" And sht.Name < "Data" And sht.Name < "Lists
Then
sht.Delete
End If

Next

End Sub


but the problem is this will prompt you whether to delete or not. Ther
is a way around this which I am not remembering at the moment

- Manges

--
mangesh_yada
-----------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...fo&userid=1047
View this thread: http://www.excelforum.com/showthread.php?threadid=31868

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to delete unwanted sheets


ok. here it is. Use

Sub DeleteSheet()

Application.DisplayAlerts = False

For Each sht In Worksheets
If sht.Name < "Log" And sht.Name < "Data" And sht.Name <
"Lists" Then
sht.Delete
End If

Next

Application.DisplayAlerts = True
End Su

--
mangesh_yada
-----------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...fo&userid=1047
View this thread: http://www.excelforum.com/showthread.php?threadid=31868

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to delete unwanted sheets


Thanks for you help - that did the trick!

Kenn

--
N E Bod
-----------------------------------------------------------------------
N E Body's Profile: http://www.excelforum.com/member.php...fo&userid=1126
View this thread: http://www.excelforum.com/showthread.php?threadid=31868

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
How to delete unwanted lines TPG Excel Discussion (Misc queries) 4 November 1st 08 10:33 PM
Delete unwanted sheet Brenda Excel Discussion (Misc queries) 6 October 19th 08 06:13 AM
Delete unwanted data JJ Excel Worksheet Functions 1 February 26th 08 08:14 AM
Macro to delete unwanted sheets Sal Excel Discussion (Misc queries) 5 March 15th 07 09:33 PM
Delete Unwanted Data Happy Excel Discussion (Misc queries) 1 August 17th 05 06:20 AM


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