我正在尝试使用Access中的Excel LinEst函数来获取给定数据集的Heat Rate曲线。我已经研究了不同的方法来使Access中的Excel函数可用,但我的代码没有成功。
当我尝试测试该过程时,收到以下错误消息。
" 1004:无法获取WorksheetFunction类的LinEst属性"
这是我的代码。我有什么不对的想法吗?非常感谢您的帮助。
Function PolyForm(yVals As Variant, xVals As Variant, PolyPower As Integer)
Dim XArr() As Variant
Dim xl As Object
Set xl = CreateObject("Excel.Application")
XArr = XArray(xVals, PolyPower)
PolyForm = xl.WorksheetFunction.LinEst(yVals, XArr, True, True)
xl.Quit
Set xl = Nothing
End Function
Function XArray(InArr, PolyPower)
Dim XArr() As Variant
Dim i As Long
Dim j As Long
ReDim XArr(1 To UBound(InArr), 1 To PolyPower)
For i = 1 To UBound(XArr)
XArr(i, 1) = InArr(i)
For j = 1 To PolyPower
XArr(i, j) = XArr(i, 1) ^ j
Next j
Next i
XArray = XArr
End Function