Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Deleting shapes in an area

Is there a way to delete shapes/objects from a preselected area? I am
currently using the macro to select whether or not to delete a specific
shape, but this takes a long time as there are many shapes/objects. A second
problem is that when the dialog box is open, you can't determine which shape
is selected.
Tim

Sub delete_objects_in_an_area()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
shp.Select 'can't determine which shape is selected
response = MsgBox("Delete shape?", vbYesNoCancel + vbCritical +
vbDefaultButton2)
If response = vbYes Then
shp.Delete
ElseIf response = vbCancel Then
Exit Sub
End If
Next
end sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Deleting shapes in an area

Select a range of cells that includes at least the top left corner of the
shapes you want delete (doesn't have to be contiguous

Sub delete_objects_in_an_area()
Dim shp As Shape
Dim rng as Range, cell as Range
if typename(Selection) < "Range" then
Msgbox "Select a range of cells that contain shapes"
exit sub
End if
set rng = Selection
For Each shp In ActiveSheet.Shapes
set cell = shp.topLeftCell
if not intersect(cell,rng) is nothing then _
shp.Delete
Next
end sub

Or use the control key to select the shapes you want to delete

Sub DeleteSelectedshapes()
Selection.Delete
End sub

or just hit the delete key.

--
Regards,
Tom Ogilvy

"Tim" wrote in message
...
Is there a way to delete shapes/objects from a preselected area? I am
currently using the macro to select whether or not to delete a specific
shape, but this takes a long time as there are many shapes/objects. A

second
problem is that when the dialog box is open, you can't determine which

shape
is selected.
Tim

Sub delete_objects_in_an_area()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
shp.Select 'can't determine which shape is selected
response = MsgBox("Delete shape?", vbYesNoCancel + vbCritical +
vbDefaultButton2)
If response = vbYes Then
shp.Delete
ElseIf response = vbCancel Then
Exit Sub
End If
Next
end sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
tim tim is offline
external usenet poster
 
Posts: 105
Default Deleting shapes in an area

Thanks. Worked like a charm.

-----Original Message-----
Select a range of cells that includes at least the top

left corner of the
shapes you want delete (doesn't have to be contiguous

Sub delete_objects_in_an_area()
Dim shp As Shape
Dim rng as Range, cell as Range
if typename(Selection) < "Range" then
Msgbox "Select a range of cells that contain

shapes"
exit sub
End if
set rng = Selection
For Each shp In ActiveSheet.Shapes
set cell = shp.topLeftCell
if not intersect(cell,rng) is nothing then _
shp.Delete
Next
end sub

Or use the control key to select the shapes you want to

delete

Sub DeleteSelectedshapes()
Selection.Delete
End sub

or just hit the delete key.

--
Regards,
Tom Ogilvy

"Tim" wrote in message
...
Is there a way to delete shapes/objects from a

preselected area? I am
currently using the macro to select whether or not to

delete a specific
shape, but this takes a long time as there are many

shapes/objects. A
second
problem is that when the dialog box is open, you can't

determine which
shape
is selected.
Tim

Sub delete_objects_in_an_area()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
shp.Select 'can't determine which shape is

selected
response = MsgBox("Delete shape?",

vbYesNoCancel + vbCritical +
vbDefaultButton2)
If response = vbYes Then
shp.Delete
ElseIf response = vbCancel Then
Exit Sub
End If
Next
end sub



.

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
Set Print Area causes Shapes to disappear mikearelli Excel Discussion (Misc queries) 0 May 14th 07 08:20 PM
Deleting Shapes aftamath Excel Discussion (Misc queries) 5 November 5th 05 12:37 AM
Deleting shapes Dr.Schwartz Excel Programming 1 October 15th 04 10:18 AM
Deleting shapes Steve Excel Programming 4 June 16th 04 05:23 PM
Deleting shapes crashes for me. (Excel 97 vba) Excel Question Excel Programming 0 October 23rd 03 02:30 AM


All times are GMT +1. The time now is 07:34 PM.

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"