Hi Everyone,
When trying to run this vba i'm getting a Debug error. I'm new to VBA so any help is appresheated.
I'm guessing my placment of statements are incorrect, but I'm sure a move advaced VBA programmer will see what I'm doing wrong
Thank you
TCB
When trying to run this vba i'm getting a Debug error. I'm new to VBA so any help is appresheated.
I'm guessing my placment of statements are incorrect, but I'm sure a move advaced VBA programmer will see what I'm doing wrong
Code:
Public Function GetXLStDev(No1 As Double, No2 As Double, No3 As Double, No4 As Double, No5 As Double, No6 As Double) As Double
Dim objExcel As Object
Set objExcel = CreateObject("Excel.Application")
Let GetXLStDev = objExcel.StDev(No1, No2, No3, No4, No5, No6)
Dim dblSum As Double, dblAvg As Double
Dim intCount As Integer
dblSum = (No1 + No2 + No3 + No4 + No5 + No6)
intCount = IIf(No1 > 0, 1, 0) _
+ IIf(No2 > 0, 1, 0) _
+ IIf(No3 > 0, 1, 0) _
+ IIf(No4 > 0, 1, 0) _
+ IIf(No5 > 0, 1, 0) _
+ IIf(No6 > 0, 1, 0)
dblAvg = dblSum / intCount
GetXLStDev = Sqr(((No1 - IIf(No1 = 0, 0, dblAvg)) ^ 2 _
+ (No2 - IIf(No2 = 0, 0, dblAvg)) ^ 2 _
+ (No3 - IIf(No3 = 0, 0, dblAvg)) ^ 2 _
+ (No4 - IIf(No4 = 0, 0, dblAvg)) ^ 2 _
+ (No5 - IIf(No5 = 0, 0, dblAvg)) ^ 2 _
+ (No6 - IIf(No6 = 0, 0, dblAvg)) ^ 2) _
/ (intCount - 1))
objExcel.Quit
Set objExcel = Nothing
End Function
Public Function Pause(PauseSeconds As Double)
Dim Start
Start = Timer
Do While Timer < Start + PauseSeconds
DoEvents
Loop
End Function
Thank you
TCB