现在,我只有 a 列中列出的零件编号列表,并且在我经常使用的一个宏中,零件被添加到其中或从中删除。
这是我现在用来删除零件号的子:
Sub DeleteIfVal(rng As Range, val)
Dim c As Range, del As Range
For Each c In rng.Cells
If c.Value = val Then
If del Is Nothing Then
Set del = c
Else
Set del = Application.Union(del, c)
End If
End If
Next c
If Not del Is Nothing Then del.Delete
End Sub
现在我希望列表包含有关部件的其他信息(部件名称、位置等),但我现在拥有的子只删除单元格而不是仅基于第一列中的单元格的整行
最佳答案
通过“Range.EntireRow”获取行本身(而不是其值),然后将其删除。
换句话说,不要使用“del.Delete”,而是使用:
del.EntireRow.Delete
关于excel - 根据单元格的值删除一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24830595/