cacahuatitaCH
New Member
- Joined
- Jan 8, 2021
- Messages
- 12
- Office Version
- 365
- Platform
- Windows
I have been trying to delete ONLY the pictures (and ideally, the added shapes) in a worksheet using this code I found in another thread here:
The problem is that this code deletes all pictures, but leaves the shapes, AND also deletes checkboxes (ActiveX control)
What I need is an alternative code that deletes pictures and shapes ONLY in the specified range.
I kept thinking I could substitute the range for row numbers, but I have no been able to make the necessary adjustment by myself.
VBA Code:
Sub DeletePic()
Set ws = ActiveSheet
Set Rng = ws.Range("A5:F500")
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
The problem is that this code deletes all pictures, but leaves the shapes, AND also deletes checkboxes (ActiveX control)
What I need is an alternative code that deletes pictures and shapes ONLY in the specified range.
I kept thinking I could substitute the range for row numbers, but I have no been able to make the necessary adjustment by myself.