Reputation: 1105
I'm trying to define the following function but am getting Compile Error: Sub or Function not defined
. The debugged is highlighting the first line. Any ideas as to what could be incorrect here?
Function MAXELSEMIN(A As Integer, B As Double, C As Double) As Double
If A = 1 Then
test = Max(B, C)
ElseIf A = -1 Then
test = Min(B, C)
Else
test = 0
End If
End Function
Upvotes: 0
Views: 76
Reputation: 50008
Use the WorksheetFunction
object to call the functions in question:
test = WorksheetFunction.Max(B, C)
test = WorksheetFunction.Min(B, C)
and then at the end add the line:
MAXELSEMIN = test
Upvotes: 1