Private Sub Worksheet_Activate()
Dim t, tablo, ub1&, ub2%, i&, j%, d As Object, dd As Object, x$, jj%, ii&, n&
t = Timer
tablo = Feuil1.Range("C8:R" & Feuil1.Range("C" & Rows.Count).End(xlUp).Row)
ub1 = UBound(tablo)
ub2 = UBound(tablo, 2)
'---heures au format texte---
For i = 2 To ub1
For j = 1 To ub2 Step 2
tablo(i, j) = Format(tablo(i, j), "h:mm:ss") 'élimine les fractions de seconde
Next j, i
'---résultats---
Set d = CreateObject("Scripting.Dictionary")
Set dd = CreateObject("Scripting.Dictionary")
For i = 2 To ub1
For j = 1 To ub2 Step 2
x = tablo(i, j)
If d.exists(x) Then If d(x) Then GoTo 2 Else GoTo 1 'gagne du temps
For jj = 1 To ub2 Step 2
If jj <> j Then
For ii = 1 To ub1
If tablo(ii, jj) = x Then Exit For
Next ii
If ii > ub1 Then d(x) = False: GoTo 1
End If
Next jj
d(x) = True
2 dd(x) = dd(x) + tablo(i, j + 1) 'somme
1 Next j, i
'---restitution---
With [A2]
n = dd.Count
If n Then
.Resize(n) = Application.Transpose(dd.keys) 'Transpose est limitée à 65536 lignes
.Offset(, 1).Resize(n) = Application.Transpose(dd.items)
End If
.Offset(n).Resize(Rows.Count - n - .Row + 1, 2).ClearContents 'RAZ en dessous
.Cells(0).Resize(n + 1, 2).Sort .Cells, xlAscending, Header:=xlYes 'tri croissant
End With
With UsedRange: End With 'actualise la barre de défilement verticale
Application.ScreenUpdating = True
If n Then MsgBox n & " lignes obtenues en " & Format(Timer - t, "0.00 \sec")
End Sub