Easy (for you) question

G

Guest

Hello!
I'm trying to get the standard deviation of the values in a one dimentional
array.
Excel obviously has the function, but the necesary argument is a range.
I was thinking of calculating the st.dev manually, but that not very cool.
Is there a way of using the items in an array as the arguments for the
Standard Deviation Worksheet.Function?
Thanks in advance,
Albert C
 
J

John Coleman

When called from VBA you can pass it an array:

Sub Test()
Dim A As Variant
A = Array(1, 2, 1, 4, 2, 3)
MsgBox Application.WorksheetFunction.StDev(A)
End Sub

(or StDevP(A) as the case may be)

Hope this helps

-John Coleman
 
D

Dave Peterson

This worked ok for me:

Hello!
I'm trying to get the standard deviation of the values in a one dimentional
array.
Excel obviously has the function, but the necesary argument is a range.
I was thinking of calculating the st.dev manually, but that not very cool.
Is there a way of using the items in an array as the arguments for the
Standard Deviation Worksheet.Function?
Thanks in advance,
Albert C
 
D

Dave Peterson

This (still) worked ok for me:

Option Explicit
Sub testme01()
Dim myArr As Variant
myArr = Array(1, 2, 3, 4, 5)
MsgBox Application.StDev(myArr)
End Sub


I could use this, too:
MsgBox Application.WorksheetFunction.StDev(myArr)
 
G

Guest

Thank you sir,
Worked Great.

Dave Peterson said:
This (still) worked ok for me:

Option Explicit
Sub testme01()
Dim myArr As Variant
myArr = Array(1, 2, 3, 4, 5)
MsgBox Application.StDev(myArr)
End Sub


I could use this, too:
MsgBox Application.WorksheetFunction.StDev(myArr)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top