我有以下代码。我希望这个删除列z中NA的所有项目...它只删除NA的第一部分而不删除其他部分。我需要添加一些东西来删除所有NA
。Sub Delete_NA()
Dim LastRow As Integer
Dim x As Integer
Dim StartRow, StopRow As Integer
For x = 0 To LastRow
If (Range("Y2").Offset(x, 0) = "NA") Then
Range("Y2").Offset(x, 0).EntireRow.Delete
x = x - 1
End If
Next x
End Sub
答案 0 :(得分:0)
尝试使用以下代码
Sub Delete_NA()
Dim LastRow, x As Long
LastRow = Range("Y" & Rows.Count).End(xlUp).Row
For x = LastRow To 1 Step -1
If Range("Y" & x).Value = "NA" Then
Range("Y" & x).EntireRow.Delete shift:=xlUp
End If
Next x
End Sub