无法获取工作表函数类的相关属性错误 [英] Unable to get correl property of the worksheetfunction class Error
问题描述
我在VBA中收到这个错误,当我尝试得到两个数组 Arr1 和 Arr2 的相关系数时,
Dim arr1()As Variant
Dim arr2()As Variant
arr1和arr2在函数中初始化。
Dim result As Double
result = Application.WorksheetFunction.Correl(arr1,arr2)
Correl
方法抛出异常
无法获取工作表函数的相关属性类别
任何想法可能是异常的原因。
编辑:
我认为这个问题发生在其中一个数组的所有元素都相同的情况下。在这种情况下,相关系数会导致#DIV0错误。
谢谢
Kiran,
两个可能的解决方案,防止这个错误...但看到你的数据将会更有帮助
- 一个(或两者)您的变体数组包含字符串而不是数字
- 您的数组的大小不等同于
I am getting this error in VBA, when I try to get the correlation coefficient of two arrays Arr1 and Arr2
Dim arr1() As Variant
Dim arr2() As Variant
arr1 and arr2 are initialized in the function.
Dim result As Double
result = Application.WorksheetFunction.Correl(arr1, arr2)
The Correl
method throws an exception
"unable to get correl property of the worksheetfunction class"
Any idea what could be the reason for the exception.
EDIT :
I think this problem occurs when one of the array has all the elements same. In this case, the correlation coefficient results in #DIV0 error.
Thanks
Kiran,
Two possible solutions that prevent this error ... but seeing your data would be much more helpful
- One (or both) your variant arrays contains strings rather than numbers
- Your arrays are not equivalent in size
这篇关于无法获取工作表函数类的相关属性错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!