ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   delete picture within a specific range (https://www.excelbanter.com/excel-programming/426243-delete-picture-within-specific-range.html)

Caroline

delete picture within a specific range
 
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
--
caroline


All times are GMT +1. The time now is 10:53 AM.

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