I am trying to write a code that if there is an IR clinic completed but all Biopsy entries are canceled for the same ID, then I want to delete the row where the IR is. Row 1 is headers. Column B is IDs, column L is either "Biopsy" or "IR clinic". Column C is either "Completed" or "Canceled"
For i = 2 To LastRow
If Range("L" & i).Value = "IR Clinic" And Range("C" & i).Value = "Completed" Then
For j = 2 To i
If Range("B" & j).Value = Range("B" & i).Value And _
Range("L" & j).Value = "Biopsy" And _
Range("C" & j).Value = "Canceled" Then
Selection.Rows(i).EntireRow.Delete
LastRow = Cells(Rows.Count, 2).End(xlUp).Row
i = i - 1
Exit For
End If
Next j
End If
Next i
The problem with this code is if there is at least one Biopsy Canceled, it deletes the IR row. What I really need is if ALL biopsy for same ID are canceled it deletes it, but if at least one is completed, it does not delete the IR. Thank you for any help in advance.
i = i - 1is covering it.