[英]User-defined type not defined error
Hi I am very new to VBA Excel Programming.嗨,我对 VBA Excel 编程非常陌生。 I keep getting a "User-defined type not defined" error.
我不断收到“未定义用户定义的类型”错误。 I searched everywhere and cannot find the answer to my specific problem.
我到处搜索,找不到我的具体问题的答案。 A lot of the solutions required adding references, which doesn't seem to apply to my situation.
很多解决方案都需要添加引用,这似乎不适用于我的情况。 The calculation returns properly but the error message drives me crazy.
计算正确返回,但错误消息让我发疯。 Also the macro call at the end is not happening.
最后的宏调用也没有发生。
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
I even tried to make a simpler version but I still get the same error.我什至尝试制作一个更简单的版本,但我仍然遇到同样的错误。
Function MinutesOver(duration As Integer)
MinutesOver = duration
'Call AddRowDeleteConstants
End Function
Any feedback would be appreciated.对于任何反馈,我们都表示感谢。 Thanks.
谢谢。
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
I to ran your function with no errors, but...我运行你的 function 没有错误,但是......
A user defined function cannot modify other cells.用户定义的 function 不能修改其他单元格。 In the call to
AddRowDeleteConstants
, whether or not it errors, the commands Copy
, Insert
and PasteSpecial
do nothing because they are in effect called from the user defined function.在对
AddRowDeleteConstants
的调用中,无论是否出错,命令Copy
、 Insert
和PasteSpecial
都不执行任何操作,因为它们实际上是从用户定义的 function 调用的。
I'm not getting any errors with your code, but maybe you need to give your function a type?我的代码没有任何错误,但也许你需要给你的 function 一个类型?
Function MinutesOver(duration As Integer) as Integer
just a guess...只是猜测...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.