Private Sub CommandButton1_Click() 'bouton Maxima
Dim tablo, ub&, resu(), minimax#, i&, a(1 To 2), j&, n&
tablo = UsedRange.Resize(UsedRange.Rows.Count + 1, 3) 'matrice, plus rapide
ub = UBound(tablo)
ReDim resu(1 To ub, 1 To 2)
minimax = -10 ^ 99
For i = 1 To ub
If tablo(i, 1) <> "" Then
a(1) = ""
a(2) = minimax
For j = i + 1 To ub
If IsNumeric(CStr(tablo(j, 3))) And tablo(j, 3) > a(2) Then
a(1) = tablo(j, 2)
a(2) = tablo(j, 3)
ElseIf tablo(j, 3) = "" Then
If a(2) > minimax Then
n = n + 1
resu(n, 1) = a(1)
resu(n, 2) = a(2)
End If
i = j - 1
Exit For
End If
Next j
End If
Next i
'---restitution---
If FilterMode Then ShowAllData 'si la feuille est filtrée
With [H3] 'cellule à adapter
If n Then .Resize(n, 2) = resu
.Offset(n).Resize(Rows.Count - n - .Row + 1, 2).ClearContents 'RAZ en dessous
End With
End Sub