Maximum of 7 calculated fields in subform

johnsqftwr

Registered User.
Local time
Today, 06:24
Joined
Jul 19, 2004
Messages
29
All,

I have 7 unbound calculated fields in the footer section of a subform.
[Text1], [Text2] etc.

Does a VBA guru have a bespoke function which will calculate the maximum of these fields in the same subform?

Any help greatly appreciated.


John
 
Here's a function for returning the maximum value from a list of values passed to it.
Code:
Function MaxValue(ParamArray arrNums() As Variant) As Double
   Dim i As Integer
   Dim Value As Variant

   Value = arrNums(0)
   For i = 0 To UBound(arrNums)
      If arrNums(i) > Value Then
         Value = arrNums(i)
      End If
   Next i
   
   MaxValue = Value

End Function

Example:
MaxValue(111.5, 333.79, 333.78) will return 333.79
.
 
John K, Many thanks.

Worked a treat.
 

Users who are viewing this thread

Back
Top Bottom