View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
the excel-arator[_2_] the excel-arator[_2_] is offline
external usenet poster
 
Posts: 3
Default select and delete all pictures in a given range

Just what I needed, thanks!

"Peter T" wrote:

Delete all pictures partly or entirely within A5:C25 on Sheet2 of
activeworkbooik -

Sub test()
Dim s As String
Dim pic As Picture
Dim rng As Range

' Set ws = ActiveSheet
Set ws = ActiveWorkbook.Worksheets("Sheet2")

Set rng = ws.Range("A5:C25")

For Each pic In ActiveSheet.Pictures
With pic
s = .TopLeftCell.Address & ":" & .BottomRightCell.Address
End With
If Not Intersect(rng, ws.Range(s)) Is Nothing Then
pic.Delete
End If
Next

End Sub

Regards,
Peter T