Web Development

General discussion


max and min

By john_wills ·
I thought there were functions max and min in VBA, as in Algol, Fortran, Cobol. But I get an error message at compilation, and have been reduced to defining them myself. Help is no help. The functions I want have this kind of definition
Def max(x,y): if x>y then x else y fi
Are these things really in VBA and if so how do I access them?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by Chimp In reply to max and min

There is no Max function, amazingly. You can do it using an Excel worksheet function or Access SQL. VBScript functions are even more limited, see the following:


Collapse -

by john_wills In reply to

The url does not work - I did take the blanks out of it and, via a text editor, get it all on one line.

Collapse -

by Gast?n Nusimovich In reply to max and min

You can insert a module in the VBA environment and define your own functions, and the use you own functions as if they were VBA functions, like this

Function MyMax(x As Double, y As Double) As Double

Dim retval As Double

If x > y Then
retval = x


retval = y

End If

MyMax = retval

End Function

Good luck !

Collapse -

by john_wills In reply to

This is the kind of thing I have been doing myself, except that I did not have the intermediate variable retval.

Collapse -

by john_wills In reply to max and min

This question was closed by the author

Related Discussions

Related Forums