嗨,我很新的VBA Excel編程。我不斷收到「用戶定義的類型未定義」錯誤。我到處搜索,找不到我的具體問題的答案。很多解決方案都需要添加引用,這似乎不適用於我的情況。計算正確返回,但錯誤消息讓我瘋狂!最後的宏調用也沒有發生。用戶定義類型未定義錯誤
Function MinutesOver(duration, start_time, end_time)
If Not (duration = "") Then
If ((duration * 60) > 600) Or (((duration * 60) + (start_time * 24 * 60)) > (TimeValue("17:00:00") * 24 * 60)) Then
MinutesOver = (duration * 60) - ((end_time - start_time) * 24 * 60)
Else
MinutesOver = ""
End If
Else
MinutesOver = ""
End If
Call AddRowDeleteConstants
End Function
我甚至試圖做出更簡單的版本,但我仍然得到相同的錯誤。
Function MinutesOver(duration As Integer)
MinutesOver = duration
'Call AddRowDeleteConstants
End Function
任何反饋,將不勝感激。謝謝。
Sub AddRowDeleteConstants()
'On Error GoTo NoConstants
With ActiveCell.EntireRow
.Copy
.Insert Shift:=xlDown
.SpecialCells(xlCellTypeConstants).ClearContents
End With
Exit Sub
'NoConstants:
'MsgBox "There were no constants to delete"
End Sub
什麼是AddRowDeleteConstants?什麼是錯誤? (如果你不能告訴,按功能MinutesOver(..線上的f9設置一個斷點,運行呼叫,當打破以運行下一行時按F8) – 2011-06-10 16:42:55
我用F8一路走過它,錯誤doesn直到完成後纔會發生(在它到達End Function行後)AddRowDeleteConstants看起來像這樣: – 2011-06-10 16:57:32