ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting shapes/objects from a preselected area (https://www.excelbanter.com/excel-programming/314436-deleting-shapes-objects-preselected-area.html)

Tim

Deleting shapes/objects from a preselected area
 
Is there a way to delete shapes/objects from a preselected area? I am trying
to use the following macro, but it takes a long time. It also has the
problem as you can't tell which object is selected when the dialog box is
open.
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
'ActiveSheet.activeShape.Select
'need to select shape first so I know whether to delete or not
response = MsgBox("Delete shape?", vbYesNoCancel + vbCritical +
vbDefaultButton2)
If response = vbYes Then
shp.Delete
ElseIf response = vbCancel Then
Exit Sub
End If
Next
end sub

Tom Ogilvy

Deleting shapes/objects from a preselected area
 
See first posting of this question for a suggestion.

--
Regards,
Tom Ogilvy


"Tim" wrote in message
...
Is there a way to delete shapes/objects from a preselected area? I am

trying
to use the following macro, but it takes a long time. It also has the
problem as you can't tell which object is selected when the dialog box is
open.
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
'ActiveSheet.activeShape.Select
'need to select shape first so I know whether to delete or not
response = MsgBox("Delete shape?", vbYesNoCancel + vbCritical +
vbDefaultButton2)
If response = vbYes Then
shp.Delete
ElseIf response = vbCancel Then
Exit Sub
End If
Next
end sub





All times are GMT +1. The time now is 05:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com