-
Clear .jpeg in a specific range
Hello Everyone,
I'm trying to clear a .jpeg from a specific range on a worksheet. A VBAX member was kind enough to provide me with the code shown below. It does a great job but it does delete all of the pics on the spreadsheet. Can it be modified so that only the .jpeg in the specified range gets cleared? I tried to modify it without success.
I appreciate your help!!
Sub Proc2()
' Remove pictures
Dim DrObj
Dim Pict
Set DrObj = wksWHMaster.DrawingObjects
For Each Pict In DrObj
If Left(Pict.Name, 7) = "Picture" Then
Pict.Select
Pict.Delete
End If
Next
End Sub
-
Assuming that wksWHMaster is a sheet,
[vba]Sub blah()
For Each Pict In wksWHMaster.Pictures
If TypeName(Pict) = "Picture" Then Pict.Select
Next
End Sub
[/vba] may work for you and is a bit tidier.
Now as to deleting a picture to be found on a range in a worksheet, each picture has a topleftcell and a bottomrightcell viz.:
[vba]Sub blaha()
For Each Pict In wksWHMaster.Pictures
If TypeName(Pict) = "Picture" Then
' MsgBox Pict.TopLeftCell.Address
' MsgBox Pict.BottomRightCell.Address
If Not Intersect(Pict.TopLeftCell, Range("I19:J20")) Is Nothing Then
Pict.Select
'Pict.delete
End If
End If
Next
End Sub[/vba]
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules