Private Sub Worksheet_Activate()
Dim d1 As Object, d2 As Object, tablo, i&, x$
With Feuil1.[A1].CurrentRegion 'CodeName de la feuille
.Columns(3).EntireColumn.Resize(, 2).Insert 'colonnes auxiliaires
tablo = .Resize(, 4)
Set d1 = CreateObject("Scripting.Dictionary")
Set d2 = CreateObject("Scripting.Dictionary")
For i = 2 To UBound(tablo)
x = CStr(tablo(i, 2))
If Not d1.exists(x) Then d1(x) = tablo(i, 1) Else If Val(tablo(i, 1)) < Val(d1(x)) Then d1(x) = tablo(i, 1)
Next
For i = 2 To UBound(tablo)
tablo(i, 3) = d1(CStr(tablo(i, 2)))
x = tablo(i, 2) & " " & tablo(i, 3)
If Not d2.exists(x) Then d2(x) = "": tablo(i, 4) = 1 'repère
Next
If .Parent.FilterMode Then .Parent.ShowAllData 'si la feuille est filtrée
.Resize(, 4) = tablo 'restitution
For i = 1 To 4
.Columns(i).Name = "_" & i 'plages nommées _1 _2 _3 _4
Next
[B3:B14].FormulaR1C1 = "=SUMPRODUCT((_3=RC1)*_4)"
[C3:N14].FormulaR1C1 = "=SUMPRODUCT((_3=RC1)*(_1=R2C))"
[B3:N14] = [B3:N14].Value 'supprime les formules
.Columns(3).EntireColumn.Resize(, 2).Delete 'supprime les colonnes auxiliaires
End With
End Sub