delete picture within a specific range

C

caroline

hello,
I am using this code found in Search results:
It works very well on a new workbook/sheet, but when I try to use it on my
existing workbook/sheet, it gives me error 13 on that line "For Each pic In
ws.Pictures"
Any pointer would be most welcome. This is driving me crazy.
Thanks
here's the full code

Dim s As String
Dim pic As Picture
Dim rng As Range

Set ws = ActiveSheet

Set rng = ws.Range("F11:J32")

For Each pic In ws.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
 

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

Top