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


Hi all,

I have a macro that creates upto about 15 sheets of pivot tables and
then copies the data onto other sheets. I would like to know how I can
delete all of these sheets as they are not needed.

These sheets all have the standard new sheet name. I.e. Sheetxx

The VBA Code for this would be tremendous :)


--
moglione1
------------------------------------------------------------------------
moglione1's Profile: http://www.excelforum.com/member.php...o&userid=26414
View this thread: http://www.excelforum.com/showthread...hreadid=508547

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Delete Multiple sheets

This should do the trick. Put it in a standard module...

Sub DeleteSheets()
Dim wks As Worksheet
On Error GoTo ErrorHandler
Application.DisplayAlerts = False
For Each wks In Worksheets
If Left(wks.Name, 5) = "Sheet" Then wks.Delete
Next wks
ErrorHandler:
Application.DisplayAlerts = False
End Sub
--
HTH...

Jim Thomlinson


"moglione1" wrote:


Hi all,

I have a macro that creates upto about 15 sheets of pivot tables and
then copies the data onto other sheets. I would like to know how I can
delete all of these sheets as they are not needed.

These sheets all have the standard new sheet name. I.e. Sheetxx

The VBA Code for this would be tremendous :)


--
moglione1
------------------------------------------------------------------------
moglione1's Profile: http://www.excelforum.com/member.php...o&userid=26414
View this thread: http://www.excelforum.com/showthread...hreadid=508547


  #3   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default Delete Multiple sheets

Try this:

After your done with the data on each sheet, before you create the next
sheet use ActiveSheet.Delete if it's the active sheet; -use your object
variable for the sheet if it's not!

Regards, GS

"moglione1" wrote:


Hi all,

I have a macro that creates upto about 15 sheets of pivot tables and
then copies the data onto other sheets. I would like to know how I can
delete all of these sheets as they are not needed.

These sheets all have the standard new sheet name. I.e. Sheetxx

The VBA Code for this would be tremendous :)


--
moglione1
------------------------------------------------------------------------
moglione1's Profile: http://www.excelforum.com/member.php...o&userid=26414
View this thread: http://www.excelforum.com/showthread...hreadid=508547


  #4   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default Delete Multiple sheets

Hi Jim,

You should be turning .DisplayAlerts back on (TRUE) in your ErrorHandler:
Regards, GS

"Jim Thomlinson" wrote:

This should do the trick. Put it in a standard module...

Sub DeleteSheets()
Dim wks As Worksheet
On Error GoTo ErrorHandler
Application.DisplayAlerts = False
For Each wks In Worksheets
If Left(wks.Name, 5) = "Sheet" Then wks.Delete
Next wks
ErrorHandler:
Application.DisplayAlerts = False
End Sub
--
HTH...

Jim Thomlinson


"moglione1" wrote:


Hi all,

I have a macro that creates upto about 15 sheets of pivot tables and
then copies the data onto other sheets. I would like to know how I can
delete all of these sheets as they are not needed.

These sheets all have the standard new sheet name. I.e. Sheetxx

The VBA Code for this would be tremendous :)


--
moglione1
------------------------------------------------------------------------
moglione1's Profile: http://www.excelforum.com/member.php...o&userid=26414
View this thread: http://www.excelforum.com/showthread...hreadid=508547


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Delete Multiple sheets

Absolutely correct on the DisplayAlerts. Thanks for noticing.
--
HTH...

Jim Thomlinson


"GS" wrote:

Hi Jim,

You should be turning .DisplayAlerts back on (TRUE) in your ErrorHandler:
Regards, GS

"Jim Thomlinson" wrote:

This should do the trick. Put it in a standard module...

Sub DeleteSheets()
Dim wks As Worksheet
On Error GoTo ErrorHandler
Application.DisplayAlerts = False
For Each wks In Worksheets
If Left(wks.Name, 5) = "Sheet" Then wks.Delete
Next wks
ErrorHandler:
Application.DisplayAlerts = False
End Sub
--
HTH...

Jim Thomlinson


"moglione1" wrote:


Hi all,

I have a macro that creates upto about 15 sheets of pivot tables and
then copies the data onto other sheets. I would like to know how I can
delete all of these sheets as they are not needed.

These sheets all have the standard new sheet name. I.e. Sheetxx

The VBA Code for this would be tremendous :)


--
moglione1
------------------------------------------------------------------------
moglione1's Profile: http://www.excelforum.com/member.php...o&userid=26414
View this thread: http://www.excelforum.com/showthread...hreadid=508547


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 can I delete multiple sheets in VBA... kurt Excel Programming 1 September 7th 05 01:20 AM
Delete rows in multiple sheets without loop? MTT727 Excel Programming 2 July 26th 05 03:07 PM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:11 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Delete Rows from multiple Sheets. drbobsled Excel Programming 3 April 7th 05 01:23 AM


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