Sub test()
Dim Horizontal As Object, Vertical As Object, i As Integer, C As Integer
C = 2
Sheets("Supports_resultats").Cells.Delete
Set Horizontal = CreateObject("Scripting.Dictionary"): Set Vertical = CreateObject("Scripting.Dictionary")
With Sheets("BDD").Range("A1").CurrentRegion
For i = 1 To .Rows.Count
If Not Horizontal.exists(.Cells(i, "D").Value) Then C = C + 1: Horizontal(.Cells(i, "D").Value) = C
If Not Vertical.exists(.Cells(i, "A").Value) Then Vertical(.Cells(i, "A").Value) = Sheets("Supports_resultats").Cells(Cells.Rows.Count, "A").End(xlUp).Offset(1).Row
Sheets("Supports_resultats").Cells(Vertical(.Cells(i, "A").Value), "A") = .Cells(i, "A").Value
Sheets("Supports_resultats").Cells(Vertical(.Cells(i, "A").Value), "B") = .Cells(i, "B").Value
Sheets("Supports_resultats").Cells(Vertical(.Cells(i, "A").Value), Horizontal(.Cells(i, "D").Value)) = .Cells(i, "C").Value
Sheets("Supports_resultats").Cells(1, Horizontal(.Cells(i, "D").Value)) = .Cells(i, "D").Value
Next
End With
v = Vertical.keys: h = Horizontal.keys
With Sheets("Supports_resultats")
Encadrement .Range(.Cells(Vertical(v(0)), "A"), .Cells(Vertical(v(UBound(v))), Horizontal(h(UBound(h))))), xlMedium
Encadrement .Range(.Cells(1, Horizontal(h(0))), .Cells(Vertical(v(UBound(v))), Horizontal(h(UBound(h))))), xlMedium
End With
End Sub