Function Classement(xquoi As Range, xplage As Range, xsens As Long, ParamArray exclus())
Dim unionExclus As Range, xrg, t, n&, aux, ech As Boolean, i&, valCherchee
Classement = ""
'quelques vérifs (que la cellule à classer n'est pas une cellule exclus)
If UBound(exclus) >= 0 Then
Set unionExclus = exclus(0)
For Each xrg In exclus: Set unionExclus = Union(unionExclus, xrg): Next xrg
If Not Intersect(xquoi, unionExclus) Is Nothing Then Exit Function
End If
'tableau des éléments à classer
ReDim t(1 To xplage.Count)
For Each xrg In xplage
If Intersect(xrg, unionExclus) Is Nothing Then n = n + 1: t(n) = xrg.Value
Next xrg
'tri du tableau (du plus petit au plus grand)
Do
ech = False
For i = 1 To n - 1
If t(i + 1) < t(i) Then aux = t(i): t(i) = t(i + 1): t(i + 1) = aux: ech = True
Next i
Loop Until Not ech
If xsens = 0 Then
For i = 1 To Int(n / 2): aux = t(i): t(i) = t(n - i + 1): t(n - i + 1) = aux: Next i
End If
'le classement
valCherchee = xquoi.Value
For i = 1 To n
If t(i) = valCherchee Then Classement = i: Exit Function
Next i
End Function