根据Col N标准删除整行

时间:2016-09-29 20:10:25

标签: excel-vba excel-2016 vba excel

如果Col Date中的单元格中包含单词N,我无法弄清楚为什么以下代码不会删除整行。

"Completed"

3 个答案:

答案 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