Hi I am very new to VBA Excel Programming. 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…
A user defined function cannot modify other cells. In the call to
AddRowDeleteConstants, whether or not it errors, the commandsCopy,InsertandPasteSpecialdo nothing because they are in effect called from the user defined function.