Sub Resultat()
Dim tablo, a1, a2, n&, d1 As Object, d2 As Object, d3 As Object
Dim i&, j&, lig&, R(999, 4)
tablo = Sheets("Base").Range("D2:G" & Sheets("Base").[D65536].End(xlUp).Row)
a1 = [C2]
a2 = [C3]
n = UBound(tablo)
Set d1 = CreateObject("Scripting.Dictionary")
Set d2 = CreateObject("Scripting.Dictionary")
Set d3 = CreateObject("Scripting.Dictionary")
For i = 1 To n
If Not d1.Exists(tablo(i, 1)) Then
d1(tablo(i, 1)) = tablo(i, 1)
d2.RemoveAll 'RAZ
d3.RemoveAll
For j = i To n
If tablo(j, 1) = tablo(i, 1) Then
d2(tablo(j, 3)) = tablo(j, 3)
If tablo(j, 4) = a1 Or tablo(j, 4) = a2 _
Then d3(tablo(j, 3)) = tablo(j, 3)
End If
Next
R(lig, 0) = tablo(i, 1)
R(lig, 1) = tablo(i, 2)
R(lig, 2) = d2.Count
R(lig, 3) = d3.Count
If R(lig, 2) Then R(lig, 4) = R(lig, 3) / R(lig, 2)
lig = lig + 1
End If
Next
'---restitution---
Application.ScreenUpdating = False
[A6:E1005].ClearContents 'RAZ
If d1.Count Then
[A6:E6].Resize(d1.Count) = R
[A6:E6].Resize(d1.Count).Sort [A6], Header:=xlNo
End If
End Sub