大家好,我遇到了一個奇怪的問題,請大家幫忙。無法獲得工作表功能的MMult屬性
錯誤消息是:
運行時錯誤 '1004'
無法獲取
WorksheetFunction
類
1的MMult
財產,我用一個程序名字是「schedule
」每天自動運行我的VBA程序,但VBA程序每天都會失敗,但是當我控制我的「時間表程序」時,再次自動運行它來試圖重現這個錯誤,我無法得到它,它運行平穩。
2,當這個錯誤發生時,Excel會顯示[完] [調試]窗口,我點擊[調試]並按[F5],它運行流暢;如果MMult的參數不正確,它會再次顯示錯誤。
3,我寫了一個子轉儲我在mmult
中使用的數據,它在發生錯誤和沒有錯誤時是一樣的。
因此,我可以假設mmult
的兩個參數是正確的,但爲什麼我每天都收到錯誤消息?
這個最難的事情是很難重現這個錯誤。
代碼:
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是這樣
1 0.34343323
1 1.32323323
1 1.21111221
1 0.33444232
. ......
微軟Windows 7家庭高級無灰64
Office 2010專業64位/ 32位SP1
你能粘貼代碼,調試器突出 – 2011-12-16 20:51:49
我不知道你在說什麼就行了。什麼是確切的錯誤(數字和消息)? – Fionnuala 2011-12-16 20:53:39