Private Sub CommandButton1_Click()
Dim datas() As Variant
Dim lg As Long
ReDim datas(0 To 1)
Dim Lig() As Range
ReDim Lig(0)
Set datas(0) = [B3].Resize(Cells(Rows.Count, 2).End(3).Row + 1)
datas(1) = [B3].Resize(Cells(Rows.Count, 2).End(3).Row + 1).Value
Dim Dico As Object
Set Dico = CreateObject("scripting.dictionary")
Dim UnionRange As Range
'on explore la colonne B à partir de la ligne 3, vers le bas
For lg = LBound(datas(1), 1) To UBound(datas(1), 1)
If Dico.Exists(datas(1)(lg, 1)) Then
Set UnionRange = Dico.Item(datas(1)(lg, 1))
Set UnionRange = Union(UnionRange, datas(0)(lg, 1))
Dico.Remove datas(1)(lg, 1)
Dico.Add datas(1)(lg, 1), UnionRange
Else
Set Lig(UBound(Lig)) = datas(0)(lg, 1)
Dico.Add datas(1)(lg, 1), Lig(UBound(Lig))
ReDim Preserve Lig(UBound(Lig) + 1)
End If
Next lg
ReDim Preserve Lig(UBound(Lig) - 1)
Application.DisplayAlerts = False
For Each k In Dico.keys
Set Value = Dico.Item(k)
Value.Merge
Next k
Application.DisplayAlerts = True
[C1] = "CALCUL FINI !": Application.Goto [A1], Scroll:=True
End Sub