Hi All—
I am trying to create a macro that searches a column ("F") to see if it contains either the word "MAINTAIN" or "REPAIR" (in a text string such as "MAINTAIN UG MTC" "MAINTAIN OH SVC" "REPAIR CONV MTC" "DISCONNECT AND REPAIR TRANSF"), keep the row if it does have either word, and delete the entire row if it does not. Here is what I have so far. It does delete some rows, but not all and I don't understand why or how to fix it.
==Sub delete_rows()
Dim lastrow As Long
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, "F").End(xlUp).Row
For row_index = lastrow - 1 To 1 Step -1
If InStr(Cells(row_index, "F").Value, "MAINTAIN") = 0 Then
ElseIf InStr(Cells(row_index, "F").Value, "REPAIR") = 0 Then
Cells(row_index, "F").EntireRow.Delete
End If
Next
Application.ScreenUpdating = True
End Sub
==
Thank you.
Bookmarks