I'm currently trying to create a loop that will look at column C starting from row 5 and compare each cell in that column until it reaches the last used cell in that column. Each cell would be checked against 8 variables to see if it matches. If the cell doesn't match any of variables the entire row must be deleted.
My current attempt looks like:
Dim AC as long
Dim LastRow as long
AC=5
LastRow= Activesheet.range("A" & Rows.count).end(xlup).row
For AC = 5 To LastRow
With Cells(AC, "C")
Do Until Cells(AC, "C").Text = OC1 Or Cells(AC, "C").Text = OC2 Or Cells(AC, "C").Text = OC3 Or Cells(AC, "C").Text = OC4 Or Cells(AC, "C").Text = NC1 Or Cells(AC, "C").Text = NC2 Or Cells(AC, "C").Text = NC3 Or Cells(AC, "C").Text = NC4
Rows(AC).EntireRow.Delete
Loop
End With
Next AC
This should insure that once a row has been deleted the new row that took it's place (Ex. Deleting the entire row 5 would result in row 6 becoming row 5) So it should exit the Do Loop when there is a match, grab the next line number and repeat until there is another match. Only the code keeps throwing an execution interrupted error. Can someone please tell me what I'm doing wrong?