Calling Test1 in Excel gives 0 for any real A and B. Why does this occur?
Public Function Min(X As Double, y As Double, Optional y2 As Double, Optional y3 As Double) As Double
Min = Application.WorksheetFunction.Min(X, y, y2, y3)
End Function
Function Test1(A As Double, B As Double)
Test1 = Min(A, B)
End Function
In Excel: =Test1(5,2).
Optional parameters use their default value if not passed into the function.
For doubles the default value is 0. if you do not provide
y2ory3essentially, you are testingApplication.WorksheetFunction.Min(A,B,0,0).If you want to change the default value, you can do something like this:
which makes
y2andy3default to10000000which would be your new built in artificial min.