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

Is there a way to delete all sheets but the active one?

Thanks Hans


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default delete all sheets but one


Application.Displayalerts = False

For Each sh In Activeworkbook.Worksheets
If sh.Name < activesheet.name then
sh.Delete
End If
Next sh

Application.Displayalerts = True

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"hans" wrote in message
...
Is there a way to delete all sheets but the active one?

Thanks Hans




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default delete all sheets but one

Sub DeleteAll()
Dim ws As Worksheet
Application.DisplayAlerts = False
For Each ws In Worksheets
If Not ws Is ActiveSheet Then
ws.Delete
End If
Next
Application.DisplayAlerts = True
End Sub


Sandy

hans wrote:
Is there a way to delete all sheets but the active one?

Thanks Hans


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default delete all sheets but one

Thanks Hans


"Sandy" schreef in bericht
oups.com...
Sub DeleteAll()
Dim ws As Worksheet
Application.DisplayAlerts = False
For Each ws In Worksheets
If Not ws Is ActiveSheet Then
ws.Delete
End If
Next
Application.DisplayAlerts = True
End Sub


Sandy

hans wrote:
Is there a way to delete all sheets but the active one?

Thanks Hans




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
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:16 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:54 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 04:38 PM


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