I'd use something like this, adjusting ranges as necessary. I put the data in Col A
Option Explicit
Sub DeleteSome()
Dim iRow As Long
Application.ScreenUpdating = False
For iRow = 1 To ActiveSheet.Cells(1, 1).CurrentRegion.Rows.Count - 1
If Not (ActiveSheet.Cells(iRow, 1).Value = "ABC123" Or ActiveSheet.Cells(iRow + 1, 1).Value = "ABC123") Then
ActiveSheet.Cells(iRow, 1).Value = True
End If
Next iRow
On Error Resume Next
ActiveSheet.Cells(1, 1).CurrentRegion.SpecialCells(xlCellTypeConstants, xlLogical).EntireRow.Delete
On Error GoTo 0
Application.ScreenUpdating = False
End Sub