Sub test()
Dim TabData() As Variant
With Sheets("Original")
fin = .Range("A" & .Rows.Count).End(xlUp).Row
TabData = .Range("A1:D" & fin).Value
End With
TabData(2, 4) = "P"
For i = LBound(TabData, 1) + 1 To UBound(TabData, 1) - 1
If TabData(i, 1) = TabData(i - 1, 1) Then
If TabData(i + 1, 1) = TabData(i, 1) Then
TabData(i + 1, 4) = "D"
TabData(i, 4) = ""
Else
TabData(i, 4) = "D"
End If
Else
TabData(i, 4) = "P"
End If
Next i
SW = "D"
For i = UBound(TabData, 1) To LBound(TabData, 1) + 1 Step -1
If TabData(i, 4) = SW Then
SW = IIf(SW = "D", "P", "D")
Else
For j = LBound(TabData, 2) To UBound(TabData, 2)
TabData(i, j) = ""
Next j
End If
Next i
With Sheets("RESULTAT ATTENDU")
.Range("A1").Resize(UBound(TabData, 1), UBound(TabData, 2)) = TabData
.Range("A1").Resize(UBound(TabData, 1), UBound(TabData, 2)).Columns(1).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End With
End Sub