Option
Explicit
Public
Function
QuantileFind(
ByVal
q
As
Double
)
As
Variant
On
Error
GoTo
ErrHandler
With
Worksheets(
"Tabelle1"
)
With
.Range(
"A2"
, .Cells(.Rows.Count,
"A"
).
End
(xlUp))
If
.Row < 2
Then
QuantileFind = Empty
Exit
Function
End
If
Dim
r
As
Excel.Range
Dim
n
As
Long
n = .Worksheet.Evaluate(
"MAX(IFERROR(LEN("
& .Address &
")-FIND("
"."
","
& .Address &
"),0))"
)
Do
While
r
Is
Nothing
And
n > 0
q = WorksheetFunction.Round(q, n)
Set
r = .Find(q, , xlValues, xlWhole)
If
r
Is
Nothing
Then
n = n - 1
Loop
End
With
End
With
If
r
Is
Nothing
Then
QuantileFind = Empty
Else
QuantileFind = r.Offset(0, 1).Value
End
If
Exit
Function
ErrHandler:
QuantileFind = CVErr(Err.Number)
End
Function