ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I return location (not value)of an Excel array's max value (https://www.excelbanter.com/excel-programming/338665-how-do-i-return-location-not-value-excel-arrays-max-value.html)

Doug

How do I return location (not value)of an Excel array's max value
 
How do I return the cell location (in addition to the value contained in the
cell) of the maximum value in an Excel array?

I'm trying to locate the row number for the maximum value in a column of
numbers.

Jim Thomlinson[_4_]

How do I return location (not value)of an Excel array's max value
 
Here is a function that returns a cell (range object) of the highes value in
a speicfied range.

Public Function MaxValue(ByVal rngToSearch As Range) As Range
Set MaxValue = rngToSearch.Find(Application.Max(rngToSearch))
End Function

Sub test()
Dim rng As Range

Set rng = MaxValue(ActiveSheet.Range("B:B"))
MsgBox rng.Value & vbTab & rng.Address
End Sub
--
HTH...

Jim Thomlinson


"Doug" wrote:

How do I return the cell location (in addition to the value contained in the
cell) of the maximum value in an Excel array?

I'm trying to locate the row number for the maximum value in a column of
numbers.


Bill Martin -- (Remove NOSPAM from address)

How do I return location (not value)of an Excel array's max value
 
Doug wrote:
How do I return the cell location (in addition to the value contained in the
cell) of the maximum value in an Excel array?

I'm trying to locate the row number for the maximum value in a column of
numbers.


The following will return the location of the max within the column. If it
returns "1" it's the first element of the array, and so forth.

[ ] = MATCH(MAX(A1:A10),A1:A10)

Bill


All times are GMT +1. The time now is 06:55 AM.

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