View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Rech Jim Rech is offline
external usenet poster
 
Posts: 2,718
Default Dynamic Arrays as arguments

I ran a simplified version of your function (below) and it worked okay. I
suspect the data in the array might not be right. I'd set a breakpoint at
the last line of the function and open the Locals windows to see what is in
the array.

Btw, unless you've set Option Base 1 at the top of the module the first
element of the array (element 0) will always be skipped by your code and
have a value of zero.

--
Jim Rech
Excel MVP

Function FindStdDev() As Single
Dim arrQty() As Integer
Dim Cell As Range, i As Integer
i = 1
For Each Cell In Range("A1:A8")
ReDim Preserve arrQty(i)
arrQty(i) = Cell.Value
i = i + 1
Next
FindStdDev = Application.WorksheetFunction.StDevP(arrQty)
End F