View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.newusers,microsoft.public.excel.worksheet.functions,microsoft.public.excel.misc
[email protected] bplumhoff@gmail.com is offline
external usenet poster
 
Posts: 136
Default Finding Location of Maximum Value in 2D Array

Hello,

I use this UDF (Excel 2002):
Function locmax(r As Range) As String
'Locates all max values of a given range
'and returns their addresses as a comma-
'separated string.
'PB V0.9
Dim dmax As Double
Dim lcount As Long
Dim ri As Range
Dim sresult As String, sdel As String, sfirst As String

dmax = Application.WorksheetFunction.Max(r)
Set ri = r.Find(what:=dmax, LookIn:=xlValues)
sfirst = ri.Address(0, 0)
Do
sresult = sresult & sdel & ri.Address(0, 0)
Set ri = r.Find(what:=dmax, after:=ri, LookIn:=xlValues)
sdel = ","
Loop Until ri.Address(0, 0) = sfirst
locmax = sresult
End Function

HTH,
Bernd