Sub Reorganiser()
Dim t, n&, i&, j&, d, clef, max&, s
With Sheets("Feuil2")
If .FilterMode Then .ShowAllData
'avec un éventuel tri
.Range("a1").CurrentRegion.Sort key1:=.Range("a1"), order1:=xlAscending, _
key2:=.Range("b1"), order2:=xlAscending, Header:=xlYes, MatchCase:=False
'fin de l'éventuel tri
'lecture des données dans le tableau t
t = .Range("a1").CurrentRegion
If UBound(t) = 1 Then Exit Sub
Set d = CreateObject("scripting.dictionary")
d.CompareMode = TextCompare
'remplissage du dictionary d
For i = 2 To UBound(t)
If Not d.Exists(t(i, 1)) Then
d.Add t(i, 1), t(i, 2)
Else
d(t(i, 1)) = d(t(i, 1)) & ";" & t(i, 2)
End If
Next i
'remplissage du tableau résultat res
ReDim res(1 To d.Count + 1, 1 To 2): max = 2
n = 1
For Each clef In d.Keys
s = Split(d(clef), ";")
If UBound(s) + 2 > max Then max = UBound(s) + 2: ReDim Preserve res(1 To d.Count + 1, 1 To max)
n = n + 1: res(n, 1) = clef
For j = 0 To UBound(s): res(n, j + 2) = s(j): Next
Next clef
'affichage
.Range("e1").CurrentRegion.Clear
res(1, 1) = t(1, 1)
For j = 1 To UBound(res, 2): res(1, j) = t(1, 2): Next
.Range("e1").Resize(UBound(res), UBound(res, 2)) = res
End With
End Sub