如果Col Date
中的单元格中包含单词N
,我无法弄清楚为什么以下代码不会删除整行。
"Completed"
答案 0 :(得分:1)
延续问题:
Sub DeleteRowBasedOnCriteria()
Dim RowToTest As Long
For RowToTest = Cells(Rows.Count, 14).End(xlUp).Row To 2 Step -1
With Cells(RowToTest, 14)
If .Value <> "Completed" Then Rows(RowToTest).EntireRow.Delete
End With
Next RowToTest
End Sub
答案 1 :(得分:0)
这个建议很简约但是......
Sub DeleteRowBasedOnCriteria()
Dim RowToTest As Long
对于RowToTest = Cells(Rows.Count,14).End(xlUp).Row To 2 Step -1
使用Cells(RowToTest,14)
如果.Value&lt;&gt; &#34;完成&#34; _
然后_
的 .EntireRow.Delete 强>
下一个RowToTest
End Sub
答案 2 :(得分:0)
我终于使用以下代码:
Sub DeleteRowBasedOnCriteria2()
表格(&#34; InProcess&#34;)。选择
Dim RowToTest As Long
For RowToTest = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
With ActiveSheet.Cells(RowToTest, 14)
If .Value = "Completed" Then ActiveSheet.Rows(RowToTest).EntireRow.Delete
End With
Next RowToTest
End Sub