ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting selected images from Excel worksheet (https://www.excelbanter.com/excel-programming/438517-deleting-selected-images-excel-worksheet.html)

Tom

Deleting selected images from Excel worksheet
 
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

Leith Ross[_796_]

Deleting selected images from Excel worksheet
 

Hello Tom,

This macro checks if the picture contains cell "L43". If it does then
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 Ross

Sincerely,
Leith Ross

'The Code Cage' (http://www.thecodecage.com/)
------------------------------------------------------------------------
Leith Ross's Profile: 75
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=170896

Microsoft Office Help



All times are GMT +1. The time now is 11:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com