jeudi 27 juillet 2017

VBA My IF statement ends after finding one iteration

Thank you for reading and your help!

I have a simple problem that I just can't figure out.

In Column A I have the below values from 1 to 20.

1. NBC997
2. EVO463
3. EVO426
4. EVO420
5. EVO826
6. EVO820
7. EVO863
8. CRO001
9. BCA915
10. SBH121
11. KEN500
12. GAM201
13. GAM1011
14. GAM101
15. SPR577
16. SPR580
17. SPR579
18. SPR576
19. DON201
20. MOR101

My formula below should be looking at column A.. and deleting the entire row if the left 2 characters <> "EV".

For whatever reason once it finds one iteration.. it stops completely and doesn't go to the next line. Please help if you can. I know I'm probably missing something really silly. Thank you!

Sub remove()

Dim i As Long

    For i = 1 To 20
        If Left(Cells(i, "A"), 2) <> "EV" Then
        Cells(i, "A").EntireRow.Delete
        Else
    End If
    Next i

End Sub

Aucun commentaire:

Enregistrer un commentaire