delete drwaings in a centain selection

  • Thread starter Thread starter bartman1980
  • Start date Start date
B

bartman1980

I try to delete all the drawings in a certain selection.

sub deletedrawings()
Range("A60:H60").Select
Range("H60").Activate
Range(Selection, Selection.End(xlDown)).Select
activecells.DrawingObjects(1).Delete
Selection.ClearContents
end sub

But I get an error with the line
activecells.DrawingObjects(1).Delete
 
Bartman,

Try something like the sub below.

HTH,
Bernie
MS Excel MVP


Sub DeleteShapes()
Dim myRange As Range
Dim myTop As Double
Dim myLeft As Double
Dim myRight As Double
Dim myBottom As Double
Dim mySh As Shape

Set myRange = Range(Range("A60"), Range("H60").End(xlDown))
myTop = myRange(1).Top
myLeft = myRange(1).Left
myRight = myRange(myRange.Count).Left + myRange(myRange.Count).Width
myBottom = myRange(myRange.Count).Top + myRange(myRange.Count).Height

For Each mySh In ActiveSheet.Shapes
If mySh.Top > myTop And mySh.Top < myBottom Then
If mySh.Left > myLeft And mySh.Left < myRight Then
mySh.Delete
End If
End If
Next mySh

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top