I have a simple code to delete pictures from a merge cell and I am curious and trying to understand why sometimes it works and some time it get a error as: Run-Time error '13' Type mismatch on the line For Each xPic1 In ActiveSheet.Pictures
.
Code
Public Sub ClearPictures_B1_L2()
Dim xPicRg1 As Range
Dim xPic1 As Picture
Dim xRg1 As Range
Set xRg1 = Range("B75:K136")
For Each xPic1 In ActiveSheet.Pictures
Set xPicRg1 = Range(xPic1.TopLeftCell.Address & ":" & xPic1.BottomRightCell.Address)
If Not Intersect(xRg1, xPicRg1) Is Nothing Then xPic1.Delete
Next
Application.ScreenUpdating = True
End Sub
Display More
It is not a chart and it is the same kinda of picture ( a snipping from the internet snipped with this code "Application.CommandBars.ExecuteMso "ScreenClipping")
and sometimes it works fine in all sheets and sometimes it only works in 1 sheet and get a error in others.
Why it would works sometimes and sometimes not? in this case should I change the code?