Deleting selected images from Excel worksheet

T

Tom

I want to remove certain images from a spreadsheet. How do I modify
the code to only select and remove the images that appear in cell L43
and not all images on the active sheet?

Public Sub Remove_Images()

DimRange = Application.Cells.Range("L43")

ScreenUpdating = False
ActiveSheet.Pictures.Select
Selection.Delete
Application.ScreenUpdating = True

End Sub
 
L

Leith Ross

Hello Tom,

This macro checks if the picture contains cell "L43". If it does the
the picture is deleted.

Code
-------------------

Sub DeletePics()

Dim Pic As Excel.Picture
Dim Rng As Range

For Each Pic In ActiveSheet.Pictures
Set Rng = Union(Pic.TopLeftCell, Pic.BottomRightCell)
If Not Intersect(Range("L43"), Rng) Is Nothing Then Pic.Delete
Next Pic

End Sub

-------------------

--
Leith Ros

Sincerely,
Leith Ross

'The Code Cage' (http://www.thecodecage.com/
 
Top