Function Valeur_proche(ref As Double, r As Range, Optional minmax = 0)
'minmax = 0 minimum, minmax <> 0 maximum
Dim maxi As Double, v As Double, mini As Double
maxi = 1E+308
For Each r In r
If IsNumeric(CStr(r)) Then
v = CDbl(r)
If minmax = 0 Then
If v <= ref Then If v > mini Then mini = v
Else
If v >= ref Then If v < maxi Then maxi = v
End If
End If
Next
Valeur_proche = IIf(minmax = 0, mini, maxi)
End Function