我希望实现一个VBA
例程,该例程会自动删除第I列和第J列中的任何内容,其中包含' delete'因为这是我设置的验证返回。我有以下代码,但我的代码在第二个循环中断,我得到一个超出范围的下标。 Haven已经能够修复它,所以如果有人可以给出建议,我将非常感激。
Sub RemoveNA()
'THIS DELETES ALL ROWS WHERE THE VALUE IN COLUMN I IS "DELETE"
Dim FoundCell As Range
Application.ScreenUpdating = False
Set FoundCell = Range("I:I").Find(what:="DELETE", LookIn:=xlValues)
Do Until FoundCell Is Nothing
FoundCell.EntireRow.Delete
Set FoundCell = Range("I:I").FindNext
Loop
'THIS DELETES ALL ROWS WHERE THE VALUE IN COLUMN J IS "DELETE"
Application.ScreenUpdating = False
Set FoundCell = Range("J:J").Find(what:="DELETE", LookIn:=xlValue)
Do Until FoundCell Is Nothing
FoundCell.EntireRow.Delete
Set FoundCell = Range("J:J").FindNext
Loop
End Sub
答案 0 :(得分:1)
看起来你错过了''在' LookIn:= xlValue'在第二个循环中。