Runtime error 13 Type Mismatch

muhittinemmi

New Member
Joined
Jun 20, 2023
Messages
19
VBA Code:
Sub Belirli_Bir_Alandaki_Resimleri_Sil()
    Dim Resim As Picture, Alan As Range
  
    Set Alan = Range("a1:a20")
  
    For Each Resim In ActiveSheet.Pictures
        If Not Intersect(Resim.TopLeftCell, Alan) Is Nothing Then
            Resim.Delete
        End If
    Next
  
    Set Alan = Nothing
 
End Sub


I am running this code in a new excel sheet without any problem to delete the picture in a3 and b20.

I get Runtime error 13 Type Mismatch Error when I add it to the module and run it on the page with my existing codes.

The error lines are as follows

For Each Resim In ActiveSheet.Pictures
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try looping through the Shapes collection instead, check whether the shape is a picture, etc . . .

VBA Code:
Sub Belirli_Bir_Alandaki_Resimleri_Sil()
    Dim Resim As Shape, Alan As Range
 
    Set Alan = Range("a1:a20")
 
    For Each Resim In ActiveSheet.Shapes
        If Resim.Type = msoPicture Then
            If Not Intersect(Resim.TopLeftCell, Alan) Is Nothing Then
                Resim.Delete
            End If
        End If
    Next
 
    Set Alan = Nothing
 
End Sub

Hope this helps!
 
Upvote 0
Solution

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top