ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Return a row with the Min or Max funtion (https://www.excelbanter.com/excel-programming/355338-return-row-min-max-funtion.html)

Adam

Return a row with the Min or Max funtion
 
Is there a way to return the column where the min or max exists rather than
returning the min or max? I am using WorksheetFunction.Min. Thank you very
much.

Bob Phillips[_6_]

Return a row with the Min or Max funtion
 
=MATCH(MAX(1:1),1:1,0)

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Adam" wrote in message
...
Is there a way to return the column where the min or max exists rather

than
returning the min or max? I am using WorksheetFunction.Min. Thank you

very
much.




Tom Ogilvy

Return a row with the Min or Max funtion
 
Assume rng is a reference to a single row

Sub FindMinColumn()
Dim rng As Range, rng1 As Range, ans As Variant
Set rng = Rows(3).Cells
ans = Application.Match(Application.Min(rng), rng, 0)
If Not IsError(res) Then
Set rng1 = rng(1, ans)
MsgBox rng1.Column
Else
MsgBox "Problems"
End If

End Sub

--
Regards,
Tom Ogilvy


"Adam" wrote in message
...
Is there a way to return the column where the min or max exists rather

than
returning the min or max? I am using WorksheetFunction.Min. Thank you

very
much.





All times are GMT +1. The time now is 02:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com