Private Sub Worksheet_Activate()
Dim d As Object, tablo, i&, j%, x$, a, b, resu(), n&
Set d = CreateObject("Scripting.Dictionary")
d.CompareMode = vbTextCompare 'la casse est ignorée
With Sheets("Feuil1").[A1].CurrentRegion
tablo = .Resize(, 4) 'matrice, plus rapde
For i = 2 To UBound(tablo)
For j = 2 To 3
x = tablo(i, j)
If x <> "" Then d(x) = d(x) + Val(tablo(i, 4))
Next j, i
End With
'---transposition---
If d.Count Then
a = d.keys: b = d.items
ReDim resu(UBound(a), 1) 'base 0
For n = 0 To UBound(a)
resu(n, 0) = a(n)
resu(n, 1) = b(n)
Next n
End If
'---restitution---
If FilterMode Then ShowAllData 'si la feuille est filtrée
With [A2] '1ère cellule de destination, à adapter
If n Then
.Resize(n, 2) = resu
.Resize(n, 2).Sort .Cells(1), xlAscending, Header:=xlYes 'tri alphabétique
End If
.Offset(n).Resize(Rows.Count - n - .Row + 1, 2).ClearContents 'RAZ en dessous
End With
End Sub