Excel VBA编译错误:类型不匹配:缺少数组或用户定义类型
'计算平均数FunctionA_V_E(ary()AsVariant)arr=Application.Transpose(Application.Transpose(ar...
'计算平均数
Function A_V_E(ary() As Variant)
arr = Application.Transpose(Application.Transpose(ary))
Dim sumtemp
For Each x In arr
n = n + 1
sumtemp = sumtemp + x
Next
A_V_E = sumtemp / n
End Function
'计算标准偏差
Function St_De(ary() As Variant)
arr = Application.Transpose(Application.Transpose(ary))
Dim X_ave
X_ave = A_V_E(arr) '计算平均值
Dim sum_x
For Each x In arr
n = n + 1
sum_x = sum_x + (x - X_ave) ^ 2
Next
St_De = Sqr(sum_x / (n - 1))
End Function
Sub test2()
Dim arr()
Dim resault
arr = Array(1, 2, 3, 4)
resault = St_De(arr)
Debug.Print resault
End Sub
运行时总是出现:类型不匹配:缺少数组或用户定义类型 不知是什么原因,求大神帮忙,谢谢
Function St_De(ary() As Variant) '传递数组是显示“类型不匹配:缺少数组或用户定义类型” 展开
Function A_V_E(ary() As Variant)
arr = Application.Transpose(Application.Transpose(ary))
Dim sumtemp
For Each x In arr
n = n + 1
sumtemp = sumtemp + x
Next
A_V_E = sumtemp / n
End Function
'计算标准偏差
Function St_De(ary() As Variant)
arr = Application.Transpose(Application.Transpose(ary))
Dim X_ave
X_ave = A_V_E(arr) '计算平均值
Dim sum_x
For Each x In arr
n = n + 1
sum_x = sum_x + (x - X_ave) ^ 2
Next
St_De = Sqr(sum_x / (n - 1))
End Function
Sub test2()
Dim arr()
Dim resault
arr = Array(1, 2, 3, 4)
resault = St_De(arr)
Debug.Print resault
End Sub
运行时总是出现:类型不匹配:缺少数组或用户定义类型 不知是什么原因,求大神帮忙,谢谢
Function St_De(ary() As Variant) '传递数组是显示“类型不匹配:缺少数组或用户定义类型” 展开
展开全部
Function A_V_E(ary() As Variant)
arr = Application.Transpose(Application.Transpose(ary))
Dim sumtemp
For Each x In arr
n = n + 1
sumtemp = sumtemp + x
Next
A_V_E = sumtemp / n
End Function
Function St_De(ary() As Variant)
Dim arr()
arr = Application.Transpose(Application.Transpose(ary))
Dim X_ave
X_ave = A_V_E(arr)
Dim sum_x
For Each x In arr
n = n + 1
sum_x = sum_x + (x - X_ave) ^ 2
Next
St_De = Sqr(sum_x / (n - 1))
End Function
Sub test2()
Dim arr()
Dim resault
arr = Array(1, 2, 3, 4)
resault = St_De(arr)
Debug.Print resault
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询