I'm a novice VBA user with a Macro I built to search down the "A" column starting with cell A3 and if a Technician's number meets the criteria listed, delete the entire row, then shift the rows up. I can't get it to catch all the criteria. If I step into the Macro and run the code manually about four times, it catches all the conditions. I'm obviously doing something wrong. I have verified that the cells in this column are formatted as numbers with no decimals. Can someone please help point out the error in my logic? Eager to learn Here's my code:
Code:
Sub SubShopTechs()
' TPRShopTechs Macro
Dim LastRow As Long, c As Range
Application.EnableEvents = False
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
On Error Resume Next
For Each c In Range("A3:A" & LastRow)
If c.Value = 413 Then
c.EntireRow.Delete shift:=xlUp
ElseIf c.Value = 417 Then
c.EntireRow.Delete shift:=xlUp
ElseIf c.Value = 425 Then
c.EntireRow.Delete shift:=xlUp
ElseIf c.Value = 431 Then
c.EntireRow.Delete shift:=xlUp
ElseIf c.Value = 434 Then
c.EntireRow.Delete shift:=xlUp
ElseIf c.Value = 436 Then
c.EntireRow.Delete shift:=xlUp
ElseIf c.Value = 438 Then
c.EntireRow.Delete shift:=xlUp
ElseIf c.Value = 439 Then
c.EntireRow.Delete shift:=xlUp
ElseIf c.Value = 440 Then
c.EntireRow.Delete shift:=xlUp
ElseIf c.Value = 441 Then
c.EntireRow.Delete shift:=xlUp
ElseIf c.Value = 442 Then
c.EntireRow.Delete shift:=xlUp
ElseIf c.Value = 511 Then
c.EntireRow.Delete shift:=xlUp
ElseIf c.Value = 536 Then
c.EntireRow.Delete shift:=xlUp
ElseIf c.Value = 541 Then
c.EntireRow.Delete shift:=xlUp
End If
Next c
On Error GoTo 0
Application.EnableEvents = True
End Sub
Last edited: