Sub Calcul()
Dim dest As Range, P As Range, Q As Range, ncol%, d As Object, c As Range, coul&, R As Range, c1 As Range, a(), i&, x, j%
Application.ScreenUpdating = False
With Feuil1 'CodeName de la feuille
Set dest = .[A27] '1ère cellule de destination, à adapter
With .[A8].CurrentRegion 'à adapter
If .Columns.Count < 3 Then Exit Sub
Set P = .Columns(1).Cells
Set Q = .Columns(3).Resize(, .Columns.Count - 2)
ncol = Q.Columns.Count
End With
End With
dest.Resize(Rows.Count - dest.Row + 1, 3).Clear 'RAZ
Set d = CreateObject("Scripting.Dictionary")
For Each c In P
If c <> "" Then
coul = c.Interior.Color
Set R = Intersect(c.MergeArea.EntireRow, Q)
For Each c1 In R
If c1.Interior.Color = coul Then d(c1.Value) = ""
Next c1
If d.Count Then
dest = c
dest.Resize(d.Count, ncol + 2).Interior.Color = coul
dest(1, 2).Resize(d.Count) = Application.Transpose(d.keys)
dest(1, 2).Resize(d.Count).Sort dest(1, 2), xlAscending, Header:=xlNo 'tri
ReDim a(1 To d.Count, 1 To ncol)
For i = 1 To d.Count
x = dest(i, 2)
For j = 1 To ncol
For Each c1 In R.Columns(j).Cells
If c1 = x And c1.Interior.Color = coul Then a(i, j) = a(i, j) + 1
Next c1, j, i
dest(1, 3).Resize(d.Count, ncol) = a
Set dest = dest(i)
d.RemoveAll
End If
End If
Next c
End Sub