(Solved) – Deletes Headings when deleting rows with different criteria

  • by
(solved)-–-deletes-headings-when-deleting-rows-with-different-criteria

I have an issue when deleting rows with certain conditions because it deletes my headers too, also ¿ is there a way to improving the deleting of rows with different criteria ?

Sub RO_FilterDelete()
Dim RowToTest As Long

For RowToTest = Cells(Rows.Count, 2).End(xlUp).row To 2 Step -1

With Cells(RowToTest, 1)
    If .Value <> "ONLINE" _
    Then _
    Rows(RowToTest).EntireRow.Delete
End With

Next RowToTest

Dim RowToTest2 As Long

For RowToTest2 = Cells(Rows.Count, 2).End(xlUp).row To 2 Step -1

With Cells(RowToTest2, 6)
    If .Value <> "CONFIRMACIÓN DE INFORMACIÓN DE CONTRATO" _
    And .Value <> "ACTUALIZACIÓN DE INFORMACIÓN DE CONTRATO" _
    Then _
    Rows(RowToTest2).EntireRow.Delete
End With

Next RowToTest2
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *