Hello I would like to write a function which takes in a range, finds the max of that range, and then returns all the values 3 columns to the left of the max as one string
In the example the desired returned string is "a,b,c,e,h,j,l"
Hello I would like to write a function which takes in a range, finds the max of that range, and then returns all the values 3 columns to the left of the max as one string
In the example the desired returned string is "a,b,c,e,h,j,l"
[VBA]Function ReturnComps(Data As Range)
Dim cel As Range, Res As String
For Each cel In Data
If cel.Value = Application.Max(Data) Then
Res = Res & cel.Offset(, -3) & ", "
End If
Next
Res = Left(Res, Len(Res) - 2)
ReturnComps = Res
End Function
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Thanks a lot mdmackillop!