2

With this code

Sub Rondom()

   Dim arr() As Double
   n = InputBox("enter your number")

   ReDim arr(1 To n) As Double
   For i = 1 To n

   arr(i) = Application.WorksheetFunction.NormSInv(Rnd()) * 0.5

   Next i
   cells(3, 4) = Application.WorksheetFunction.Percentile(arr, 0.01)

End Sub

when I enter 60000 for n it works fine. But when I enter 70000, I receive an error saying "type mismatch" and this line

cells(3, 4) = Application.WorksheetFunction.Percentile(arr, 0.01)

is highlighted.

1
  • 1
    I'm guessing that the Percentile function is expecting a Variant array with 16-bit dimensions and that it's failing trying to do the implicit conversion. (The upper limit of unsigned 16-bits is 65535). Jan 1, 2014 at 16:57

1 Answer 1

1

=PERCENTILE() can contain at most 8191 data elements.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.