Sub EnLigne()
Dim PresenceTitre As Boolean, der&, t, ref, i&, n&, k&, max&, CellulleRes As Range
Application.ScreenUpdating = False
With Sheets("Feuil1")
PresenceTitre = Not (IsDate(.Range("b1")))
If .FilterMode Then .ShowAllData
der = .Cells(.Rows.Count, "a").End(xlUp).Row
.Range("d1").CurrentRegion.Clear
.Range("d1").Resize(der, 2) = .Range("a1").Resize(der, 2).Value
.Range("d1").Resize(der, 2).Sort key1:=.Range("d1"), order1:=xlAscending, Header:=IIf(PresenceTitre, xlYes, xlNo)
t = .Range("d1").Resize(der, 2)
.Range("d1").Resize(der).RemoveDuplicates Columns:=1, Header:=IIf(PresenceTitre, xlYes, xlNo)
der = .Cells(.Rows.Count, "d").End(xlUp).Row
.Range("e1").EntireColumn.Clear
ReDim r(1 To der, 1 To 1)
n = 1: ref = t(1, 1): r(n, 1) = t(1, 2): k = 1: max = 1
For i = 2 To UBound(t)
If t(i, 1) = ref Then
r(n, 1) = r(n, 1) & ";" & t(i, 2)
k = k + 1
If k > max Then max = k
Else
n = n + 1: ref = t(i, 1): r(n, 1) = t(i, 2): k = 1
End If
Next i
.Range("e1").Resize(UBound(r), UBound(r, 2)) = r
ReDim f(0 To max - 1)
For i = 0 To max - 1: f(i) = Array(i + 1, xlDMYFormat): Next
.Range("e1").Resize(UBound(r)).TextToColumns Destination:=.Range("e1"), DataType:=xlDelimited, Semicolon:=True, FieldInfo:=f
.Range("d1").Resize(der, max + 1).Interior.Color = RGB(225, 225, 225)
.Range("d1").Resize(, max + 1).EntireColumn.AutoFit
.Range("e1").HorizontalAlignment = xlRight
End With
End Sub