PDA

View Full Version : [SOLVED] Using stdev() function in VBA



volabos
08-12-2014, 11:28 AM
Hi again,

I am getting trouble to use Excel's stdev() function in VBA. If I use that function in VBA, the result is not matching with what we get if I use in Excel-sheet.

I am attaching my workout file. I created asd() sub where I use stdev() function. Also calculated standard-deviation in excel-sheet itself. There is mis-match. Can somebody help me out to understand why I am getting the difference?

Thanks for your help.

Regards,

Paul_Hossler
08-12-2014, 12:06 PM
Option Explicit

Sub asd()
Dim i As Long

'default starting index is 0
'so you actually had 21 elements with the first = 0
Dim My_Array(1 To 20) As Double

For i = 1 To 20
My_Array(i) = i
Next

MsgBox Application.WorksheetFunction.StDev(My_Array)

End Sub



Paul

volabos
08-12-2014, 12:50 PM
Thank you