On Oct 26, 9:58 am, bartman1980 <bartman1...@hotmail.com> wrote:
> I tried to delete all the drawings in a certain selection.
>
> sub deletedrawings()
> Sheets("Resultaat").Select
> Range("A60:H60").Select
> Range("H60").Activate
> Range(Selection, Selection.End(xlDown)).Select
> activecells.DrawingObjects(1).Delete
> Selection.ClearContents
> end sub
>
> But he gives an error on the line:
> activecells.DrawingObjects(1).Delete
>
> Note: searching and fine the drawing isn't an option because this is
> totally random.
> I just want to delete all drawings ans cells in the selection I made.
Hi
ActiveCells does not have a DrawingObjects property, hence the error.
try this, which will delete any shape whose top left corner or bottom
rigth corner is in the range (though you might only have the bottom
left corner in the range....puzzle that one out yourself!)
Sub deletedrawings()
Dim myShape As Shape
Sheets("Resultaat").Select
Range("A60:H60").Select
Range("H60").Activate
Set myRange = Range(Selection, Selection.End(xlDown))
myRange.Select
For Each myShape In Sheets("Resultaat").Shapes
Set Testrange1 = Intersect(myShape.TopLeftCell, myRange)
Set TestRange2 = Intersect(myShape.BottomRightCell, myRange)
If Not TestRange1 Is Nothing Or Not TestRange2 Is Nothing Then
myShape.Delete
End If
Next myShape
Selection.ClearContents
End Sub
regards
Paul
|