Thread: Average
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Average

Because the array has 16 elements not 15.
For x = 0 To 15 works.

An array starts on zero unless you have set it to 1 in an Option Base
Statement. See help for more info on this.

Regards,

Ossiemac

"RobcPettit" wrote:

Hi Im trying to figure out why:
Dim j As Variant, x As Variant, k as variant
Dim arr(15) As Single

For x = 1 To 15
arr(j) = 5
j = j + 1
Next x

j = Application.WorksheetFunction.Average(arr)
k = Application.WorksheetFunction.StDev(arr),
does not return the expected results of 5 and 0. I get 4.68 and 1.25.
Any Ideas. Regards Robert