删除行直到达到某个值

时间:2015-10-29 19:09:52

标签: excel vba excel-vba

我需要一次删除一行并循环直到activecell =" X" 为什么不像这项工作那么简单?

Sub SubMac4_1Loop()
    Do Until ActiveCell.Value <> "X"
        Selection.EntireRow.Delete
    Loop
End Sub

2 个答案:

答案 0 :(得分:2)

你的叙述与你的代码直接矛盾。

删除行,直到ActiveCell等于 X

Sub SubMac4_1Loop()
    Do Until ActiveCell.Value = "X"
        Selection.EntireRow.Delete
    Loop
End Sub

删除行,直到ActiveCell不等于 X

Sub SubMac4_1Loop()
    Do Until ActiveCell.Value <> "X"
        Selection.EntireRow.Delete
    Loop
End Sub

答案 1 :(得分:1)

Do Until ActiveCell.Value <> "X"

只要NOT activecell不是X =&gt;做活动的单元格= x

Do While ActiveCell.Value <> "X"

 Do Until ActiveCell.Value = "X"

会这样做