删除marged单元格中的图像

我想删除不同的图像(我复制图像到这个单元格,使用VBA代码,所以每个图像都有另一个名字),在合并单元格(我不想unmarged单元格)。 在这个工作表上我有另一个图像,所以我不能使用这样的代码:

ActiveSheet.Shapes.SelectAll Selection.Delete 

试试这个代码(Q与此有关):

 Sub deletePicturesFromMergedCells() Dim sh As Shape, ws As Worksheet Dim rng As Range Set ws = Worksheets("character") For Each sh In ws.Shapes 'if shape is picture If sh.Type = msoPicture Or sh.Type = msoLinkedPicture Then 'get entire range where picture placed Set rng = ws.Range(sh.TopLeftCell, sh.BottomRightCell) 'if picture is in range A8 (with megred cells) then delete it If Not Intersect(rng, ws.Range("A8").MergeArea) Is Nothing Then sh.Delete End If End If Next sh End Sub