Bonsoir patrick1957, dorierl
Comme ceci :
Restitution dans la feuille placée en 2ème position dans ton classeur
Option Explicit
Sub test()
Dim a, w(), i As Long, j As Long, n As Long, e, v, dico As Object
Set dico = CreateObject("Scripting.Dictionary")
dico.CompareMode = 1
With Sheets("Liste des composant").Range("A9").CurrentRegion
a = .Value
For i = 2 To UBound(a, 1)
If Not dico.exists(a(i, 2)) Then
Set dico(a(i, 2)) = _
CreateObject("Scripting.Dictionary")
dico(a(i, 2)).CompareMode = 1
End If
If Not dico(a(i, 2)).exists(a(i, 10)) Then
ReDim w(1 To UBound(a, 2))
For j = 1 To UBound(a, 2)
w(j) = a(i, j)
Next
dico(a(i, 2))(a(i, 10)) = w
Else
w = dico(a(i, 2))(a(i, 10))
w(4) = w(4) + a(i, 4)
dico(a(i, 2))(a(i, 10)) = w
End If
Next
Application.ScreenUpdating = False
With Sheets(2).Cells(1)
.CurrentRegion.Clear
With .Resize(1, UBound(a, 2))
.Value = a: n = 1
For Each e In dico
For Each v In dico(e)
.Offset(n).Value = dico(e)(v)
n = n + 1
Next
Next
End With
With .CurrentRegion
With .Font
.Name = "calibri"
.Size = 10
End With
.VerticalAlignment = xlCenter
.Borders(xlInsideVertical).Weight = xlThin
.BorderAround Weight:=xlThin
With .Rows(1)
.Font.Size = 11
.Interior.ColorIndex = 46
.BorderAround Weight:=xlThin
End With
.Columns.AutoFit
End With
.Parent.Activate
End With
Set dico = Nothing
End With
Application.ScreenUpdating = True
End Sub
klin89