0

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

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.