View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_3_] Patrick Molloy[_3_] is offline
external usenet poster
 
Posts: 27
Default Can you identify the maximum value in an array?

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.)