Ref: From the Help menu on using the Percentile function:
If the array has more than 8,191 values then it will not work. I guess this
resolves the Q on why worksheetfunction.percentile returns errors with arrays
of 250k to 1mio values
Rgds,
BR
PERCENTILE
See Also
Returns the k-th percentile of values in a range. You can use this function
to establish a threshold of acceptance. For example, you can decide to
examine candidates who score above the 90th percentile.
Syntax
PERCENTILE(array,k)
Array is the array or range of data that defines relative standing.
K is the percentile value in the range 0..1, inclusive.
Remarks
If array is empty or contains more than 8,191 data points, PERCENTILE
returns the #NUM! error value.
If k is nonnumeric, PERCENTILE returns the #VALUE! error value.
If k is < 0 or if k > 1, PERCENTILE returns the #NUM! error value.
If k is not a multiple of 1/(n - 1), PERCENTILE interpolates to determine
the value at the kth percentile.
Example
PERCENTILE({1,2,3,4},0.3) equals 1.9
Bernie Deitrick said:
BR,
You can use
MyVal = Application.worksheetfuntion.percentile(Array, 0.99)
within VBA, without writing the array to the sheet.
HTH,
Bernie
MS Excel MVP