如何从包含图像的列中删除空白单元格?

时间:2015-01-14 09:55:20

标签: excel image

我有一张excel表,其中一列有图像。我需要删除不包含图像的每一行。所以,我需要抓住包含列的图像中的所有单元格。请帮忙

1 个答案:

答案 0 :(得分:0)

以下是 A

列中图片的示例
Sub RowKiller()
    Dim s As Shape, rPic As Range, r As Range
    Dim wMAX As Long, i As Long
    Set rPic = Nothing

    For Each s In ActiveSheet.Shapes
        Set r = s.TopLeftCell
        If wMAX < r.Row Then
            wMAX = r.Row
        End If
        If rPic Is Nothing Then
            Set rPic = r
        Else
            Set rPic = Union(rPic, r)
        End If
    Next s

    For i = wMAX To 1 Step -1
        If Intersect(rPic, Cells(i, 1)) Is Nothing Then
            Cells(i, 1).EntireRow.Delete
        End If
    Next i
End Sub

<强>之前:

enter image description here

<强>后:

enter image description here