I think the solution is to put some code at the beginning that can select the images in the cell range and delete them, before the new data is imported.
I came across a solution that Selects all images in the worksheet and deletes them, But I have other images that I need to keep.
Is is possible to tell it to select all images in a specific range of cells?
Hi Milena
Welcome to the forum.
Just select the required range and then run the macro below.
Sub DeletePictures()
Dim Sh As Shape
For Each Sh In ActiveSheet.Shapes
If Not Application.Intersect(Sh.TopLeftCell, Range(Selection.Address)) Is Nothing Then
Sh.Delete
End If
Next Sh
End Sub
Hope this helps.
Sunny
Thank you! The Code that ended up working is this
Sub DeleteImage() Dim pic As Picture ActiveSheet.Unprotect For Each pic In ActiveSheet.Pictures If Not Application.Intersect(pic.TopLeftCell, range("H10:R24")) Is Nothing Then pic.Delete End If Next pic End Sub
Hi Milena
Glad to know you got it solved.
Sunny
Hi
i Tried the exact code and it does nothing for me. idk if its because of my image format (GIF)
Sheets("Print PG").Select
Dim pic As Picture
For Each pic In ActiveSheet.Pictures
If Not Intersect(pic.TopLeftCell, Range("A85:K101")) Is Nothing Then
pic.Delete
End If
Hi Tolu
Your codes looks incomplete.
Both Milena's and my codes work on GIF as well.
Make sure that the images are inside the range you specified.
Why don't you copy our codes and retry again.
Sunny