Thread
:
Can you identify the maximum value in an array?
View Single Post
#
5
Posted to microsoft.public.excel.programming
Brad Patterson
external usenet poster
Posts: 16
Can you identify the maximum value in an array?
This works very well. Just when I think there isnıt a function to do what I
want ... There it is. ...
Thanks again,
Brad.)
in article , Patrick Molloy at
wrote on 10/7/03 10:00 PM:
WorksheetFunction.Match(max, arr, False)
Example
Sub test()
Dim ar(1 To 5) As Long
Dim i As Long
Dim max As Long
For i = 1 To 5
ar(i) = Int(Rnd * 1000)
Next
max = Application.WorksheetFunction.max(ar)
Debug.Print max; " @ "; _
WorksheetFunction.Match(max, ar, False)
End Sub
Patrick Molloy
Microsoft Excel MVP
-----Original Message-----
Dim Arr(5) as integer
Arr(2) = 99
Arr(3) = 101
How do I then find out what the maximum value is, and
what position itıs at
in this type of array * i.e. for the above, the maximum
is 101, at position
3.
Iıve had success with
Application.WorksheetFunction.Large(Arr, 1)
But still canıt get the position of that number.
Iım attempting this with an array that is 1000 in size
if thatıs going to
be a problem ...
Thanks,
Brad.)
Reply With Quote
Brad Patterson
View Public Profile
Find all posts by Brad Patterson