Max value between some Text boxes

  • Thread starter Thread starter an
  • Start date Start date
A

an

I have 10 Text boxes with time values.
Where is possible any Text box without time value.

In 11th Text box I need formulae to display MAX value
between those Text boxes.

Thanks in advance.
an
 
Paste the function below into a module.
On your form, set the 11th text box's ControlSource to:
=Largest([Text1], [Text2], ..., [Text10])


Function Largest(ParamArray varValues()) As Variant
Dim i As Integer 'Loop controller.
Dim varMax As Variant 'Largest value found so far.

varMax = Null 'Initialize to null

For i = LBound(varValues) To UBound(varValues)
If IsNumeric(varValues(i)) Then
If varMax >= varValues(i) Then
'do nothing
Else
varMax = varValues(i)
End If
End If
Next

Largest = varMax
End Function
 
Thanks for your reply,

How I post in Report questions, I forgot to tell:
Is to the Report.
I tryed in Report but, I think, don't result...
Thanks.
an
-----Original Message-----
Paste the function below into a module.
On your form, set the 11th text box's ControlSource to:
=Largest([Text1], [Text2], ..., [Text10])


Function Largest(ParamArray varValues()) As Variant
Dim i As Integer 'Loop controller.
Dim varMax As Variant 'Largest value found so far.

varMax = Null 'Initialize to null

For i = LBound(varValues) To UBound(varValues)
If IsNumeric(varValues(i)) Then
If varMax >= varValues(i) Then
'do nothing
Else
varMax = varValues(i)
End If
End If
Next

Largest = varMax
End Function

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I have 10 Text boxes with time values.
Where is possible any Text box without time value.

In 11th Text box I need formulae to display MAX value
between those Text boxes.

Thanks in advance.
an


.
 
Sorry, AB

Configuration...

I changed , to ; and work fine!

Many thanks.
an
-----Original Message-----
Paste the function below into a module.
On your form, set the 11th text box's ControlSource to:
=Largest([Text1], [Text2], ..., [Text10])


Function Largest(ParamArray varValues()) As Variant
Dim i As Integer 'Loop controller.
Dim varMax As Variant 'Largest value found so far.

varMax = Null 'Initialize to null

For i = LBound(varValues) To UBound(varValues)
If IsNumeric(varValues(i)) Then
If varMax >= varValues(i) Then
'do nothing
Else
varMax = varValues(i)
End If
End If
Next

Largest = varMax
End Function

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I have 10 Text boxes with time values.
Where is possible any Text box without time value.

In 11th Text box I need formulae to display MAX value
between those Text boxes.

Thanks in advance.
an


.
 
Back
Top