Sub TriDonnées()
Dim Pl As Range, i As Long, j As Long, Lig As Long, Flag As Boolean
Application.ScreenUpdating = False
Set Pl = Range("A1").CurrentRegion
Set Pl = Pl.Offset(1).Resize(Pl.Rows.Count - 1, Pl.Columns.Count)
For i = 1 To Pl.Rows.Count
If Pl.Cells(i, Pl.Columns.Count).Offset(, 1) <> "traité" Then
Lig = Lig + 1
Flag = False
Select Case Pl.Cells(i, Pl.Columns.Count).Value
Case Is = "DATABASE"
Range(Pl.Cells(i, 1), Pl.Cells(i, Pl.Columns.Count)).Copy Pl.Cells(Lig, Pl.Columns.Count).Offset(, 2)
Pl.Cells(i, Pl.Columns.Count).Offset(, 1) = "traité"
For j = Lig + 1 To Pl.Rows.Count
If Pl.Cells(j, 1).Value & Pl.Cells(j, 2).Value & Pl.Cells(j, 5).Value = _
Pl.Cells(i, 1).Value & Pl.Cells(i, 2).Value & Pl.Cells(i, 5).Value And Pl.Cells(j, Pl.Columns.Count) = "AOT" Then
Range(Pl.Cells(j, 1), Pl.Cells(j, Pl.Columns.Count)).Copy Pl.Cells(Lig, Pl.Columns.Count).Offset(, Pl.Columns.Count + 2)
Pl.Cells(j, Pl.Columns.Count).Offset(, 1) = "traité"
Flag = True
Exit For
End If
Next j
If Flag = False Then Pl.Cells(Lig, Pl.Columns.Count).Offset(, Pl.Columns.Count + 2) = "Nil"
Case Else
Range(Pl.Cells(i, 1), Pl.Cells(i, Pl.Columns.Count)).Copy Pl.Cells(Lig, Pl.Columns.Count).Offset(, Pl.Columns.Count + 2)
Pl.Cells(i, Pl.Columns.Count).Offset(, 1) = "traité"
For j = i + 1 To Pl.Rows.Count
If Pl.Cells(j, 1).Value & Pl.Cells(j, 2).Value & Pl.Cells(j, 5).Value = _
Pl.Cells(i, 1).Value & Pl.Cells(i, 2).Value & Pl.Cells(i, 5).Value And Pl.Cells(j, Pl.Columns.Count) = "DATABASE" Then
Range(Pl.Cells(j, 1), Pl.Cells(j, Pl.Columns.Count)).Copy Pl.Cells(Lig, Pl.Columns.Count).Offset(, 2)
Pl.Cells(j, Pl.Columns.Count).Offset(, 1) = "traité"
Flag = True
Exit For
End If
Next j
If Flag = False Then Pl.Cells(Lig, Pl.Columns.Count).Offset(, 2) = "Nil"
End Select
End If
Next i
Range(Pl.Cells(1, Pl.Columns.Count + 1), Pl.Cells(Pl.Columns.Rows.Count, Pl.Columns.Count + 1)).ClearContents
Application.ScreenUpdating = True
End Sub