Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Code to delete shapes in copied sheets

I have a form/macro that allows users to select sheets from a workbook and
then copies these to a new workbook. Some of these sheets have shapes which
need deleting. I am having trouble with the following code so need help. The
new workbook does not yet have a name as the user saves it as what ever they
need it to be.

For i = 1 To Sheets.count
ActiveWorkbook.Sheets(i).Activate
Set myDocument = ActiveWorkbook.Sheets(i).Name
myDocument.Shapes.SelectAll
Selection.Delete
Next i

Thanks in advance
Nelly
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Code to delete shapes in copied sheets

there are obviously better ways, but this is quick & simple

Sub shapekiller()

Dim ws As Worksheet
Dim sh As Shape

For Each ws In Worksheets
For Each sh In ws.Shapes
sh.Delete
Next
Next

End Sub

"nelly" wrote in message
...
I have a form/macro that allows users to select sheets from a workbook and
then copies these to a new workbook. Some of these sheets have shapes
which
need deleting. I am having trouble with the following code so need help.
The
new workbook does not yet have a name as the user saves it as what ever
they
need it to be.

For i = 1 To Sheets.count
ActiveWorkbook.Sheets(i).Activate
Set myDocument = ActiveWorkbook.Sheets(i).Name
myDocument.Shapes.SelectAll
Selection.Delete
Next i

Thanks in advance
Nelly


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Code to delete shapes in copied sheets

Nelly,

Deleting 'ALL' shapes can be dangerous, you may end up deleting things you
don't want to but if that's what you want try this but note it will delete
all shapes so try it on a test workbook

Dim sh As Shape
For i = 1 To Worksheets.Count
For Each sh In ActiveWorkbook.Sheets(i).Shapes
sh.Delete
Next
Next

Mike

"nelly" wrote:

I have a form/macro that allows users to select sheets from a workbook and
then copies these to a new workbook. Some of these sheets have shapes which
need deleting. I am having trouble with the following code so need help. The
new workbook does not yet have a name as the user saves it as what ever they
need it to be.

For i = 1 To Sheets.count
ActiveWorkbook.Sheets(i).Activate
Set myDocument = ActiveWorkbook.Sheets(i).Name
myDocument.Shapes.SelectAll
Selection.Delete
Next i

Thanks in advance
Nelly

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
Code to delete shapes each time a sheet is deactivated DlgomesBR Excel Programming 2 November 4th 07 12:51 PM
code to delete sheets not in use based on a cell's drop down list kangasnat Excel Worksheet Functions 2 September 20th 07 03:08 AM
Copy pasting Rows, but need to Delete any Shapes/Pictures that are within copied rows Corey Excel Programming 2 August 1st 07 02:02 AM
Delete worksheets and the code sheets remain? Mike[_106_] Excel Programming 2 April 2nd 06 10:43 PM
Copied shapes are some times oblate mihai Excel Programming 0 February 4th 04 08:43 AM


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