作者:花开不美 | 来源:互联网 | 2023-06-03 07:13
everyone,Igotastrangeproblem,pleasehelp.每个人,我有一个奇怪的问题,请帮忙。theerrormessageis:错误信息是:
everyone, I got a strange problem, please help.
每个人,我有一个奇怪的问题,请帮忙。
the error message is:
错误信息是:
Run-time error '1004'
运行时错误“1004”
Unable to get the MMult
property of the WorksheetFunction
class
无法获得WorksheetFunction类的MMult属性
1, I use a program name is "schedule
" to automaticly run my VBA program everyday, but the VBA program will fail everyday, but when I control my "schedule program" to automatically run it again to try to reproduce this error, I can't get it, it run smooth.
1、我每天用一个程序名“schedule”来自动运行我的VBA程序,但是VBA程序每天都会失败,但是当我控制我的“schedule program”来自动重新运行它来尝试重现这个错误时,我无法得到它,它运行得很顺利。
2, When this error occured, Excel will show [end] [debug] window, I click [debug] and press [F5], it run smooth; it supposes show error again if parameters for MMult are incorrect.
2、当出现此错误时,Excel会显示[end] [debug]窗口,点击[debug],按[F5],运行顺畅;假设MMult参数不正确,则再次显示错误。
3, I have written a sub to dump my data which use in mmult
, it are same in error occur and no error.
3、我已经写了一个subto dump my data which use in mmult, it is same in error happen and no error。
so, I can assume the two parameters for mmult
are correct, but why I got the error message everyday?
所以,我可以假设mmult的两个参数是正确的,但是为什么我每天都会收到错误消息呢?
this most hard thing is it is hard to reproduce this error.
最困难的是很难重现这个错误。
code:
代码:
Public Function Regression(ByVal X As Variant, ByVal y As Variant)
writelog ("Regression")
writelog ("dump x")
Call dumpRange(X, 2)
writelog ("dump y")
Call dumpRange(y, 1)
Dim xtrans, temp, temp2, b
xtrans = Application.WorksheetFunction.Transpose(X)
temp = Application.WorksheetFunction.MMult(xtrans, X) ' occour error on this line
temp = Application.WorksheetFunction.MInverse(temp)
temp2 = Application.WorksheetFunction.MMult(xtrans, y)
b = Application.WorksheetFunction.MMult(temp, temp2)
Regression = b
End Function
X is a Range like this
X是这样的一个范围。
1 0.34343323
1 1.32323323
1 1.21111221
1 0.33444232
. ......
Window 7 home preminum 64bit
窗口7家庭预科64位
office 2010 professional 64bit / 32bit sp1
office 2010专业64位/ 32位sp1
3 个解决方案