I am looking to implement a VBA routine which deletes automatically anything in column I&J which has the word 'delete' in it because this is a validation return which I have set up. I have the following code, yet my code breaks on the second loop whereby I get a subscript out of range. Haven't been able to fix it so if someone could give advice, would be much appreciated.
Sub RemoveNA()
'THIS DELETES ALL ROWS WHERE THE VALUE IN COLUMN I IS "DELETE"
Dim FoundCell As Range
Application.ScreenUpdating = False
Set FoundCell = Range("I:I").Find(what:="DELETE", LookIn:=xlValues)
Do Until FoundCell Is Nothing
FoundCell.EntireRow.Delete
Set FoundCell = Range("I:I").FindNext
Loop
'THIS DELETES ALL ROWS WHERE THE VALUE IN COLUMN J IS "DELETE"
Application.ScreenUpdating = False
Set FoundCell = Range("J:J").Find(what:="DELETE", LookIn:=xlValue)
Do Until FoundCell Is Nothing
FoundCell.EntireRow.Delete
Set FoundCell = Range("J:J").FindNext
Loop
End Sub
Application.ScreenUpdating = Falsetwice. Just use it once in the beginning and set it toTrueat the end. Second, just changeFoundCellto checkRange("I:J"). Two loops are unnecessary when you can do it with one. Third, missingsinLookIn:=xlValuesin second loop.