我有一张excel表,其中一列有图像。我需要删除不包含图像的每一行。所以,我需要抓住包含列的图像中的所有单元格。请帮忙
答案 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
<强>之前:强>
<强>后:强>