I need a function which, when passed a long array, returns the highest element.
Printable View
I need a function which, when passed a long array, returns the highest element.
You mean
dim j as integer
j = UBound(arrayname)
debug.print arrayname(j)
?
No. I meant the highest value not subscript. It's Ok. I found what I was looking for in a previous thread.
(Ned Flander's impression)
Okilley Dokilley
(/Ned FLander's impression)
Try this function:
Private Function MaxElement(a())
el = LBound(a)
Max = a(el)
For i = LBound(a) To UBound(a)
If a(i) > Max Then
Max = a(i)
el = i
End If
Next
MaxElement = el
End Function