Hi Simarui,
Try this:
Sub ABC(): Dim r As Long, i As Long
r = 2: Do Until Cells(r, 1) = "" And Cells(r + 1, 1) = ""
ReComp:
If Trim(Cells(r, 1)) = "" Then
r = r + 1: GoTo ReComp: End If
If Trim(Cells(r, 1)) = "a" Then
NoComp:
If Trim(Cells(r + 1, 1)) = "b" Then
HalfComp:
If Cells(r + 2, 1) = "c" Then
r = r + 3: GoTo FullComp
Else: Cells(r + 2, 1).EntireRow.Insert
r = r + 3: GoTo FullComp: End If
Else: Cells(r + 1, 1).EntireRow.Insert 'the b row
GoTo HalfComp: End If
Else: Cells(r, 1).EntireRow.Insert: GoTo NoComp: End If
FullComp: Loop
End Sub
Bookmarks