Article ID: 139574
Article Last Modified on 1/19/2007
For this
address Use this formula
------------------------------------------------------------------------
Cell with
largest
value =CELL("address",OFFSET(A1,MATCH(MAX(A1:A10),A1:A10,0)-1,0))
Cell with
smallest
value =CELL("address",OFFSET(A1,MATCH(MIN(A1:A10),A1:A10,0)-1,0))
To return the address of a cell in a row (in this example, column A, cells
A1:J1), use the appropriate formula in the following table.
For this
address Use this formula
------------------------------------------------------------------------
Cell with
largest
value =CELL("address",OFFSET(A1,0,MATCH(MAX(A1:J1),A1:J1,0)-1))
Cell with
smallest
value =CELL("address",OFFSET(A1,0,MATCH(MIN(A1:J1),A1:J1,0)-1))
Function MaxAddress(The_Range)
' Sets variable equal to maximum value in the input range.
MaxNum = Application.Max(The_Range)
' Loop to check each cell in the input range to see if equals the
' MaxNum variable.
For Each cell In The_Range
If cell = MaxNum Then
' If the cell value equals the MaxNum variable it
' returns the address to the function and exits the loop.
MaxAddress = cell.Address
Exit For
End If
Next cell
End Function
To find the cell address of the smallest value in an adjacent range,
substitute the Min() function for the Max() function as in the following
example:
Function MinAddress(The_Range)
' Sets variable equal to minimum value in the input range.
MinNum = Application.Min(The_Range)
' Loop to check each cell in the input range to see if equals the
' min variable.
For Each cell In The_Range
If cell = MinNum Then
' If the cell value equals the max variable it
' returns the address to the function and exits the loop
MinAddress = cell.Address
Exit For
End If
Next cell
End Function
163435 VBA: Programming Resources for Visual Basic for Applications
274705 OFF2001: Programming Resources for Visual Basic for Applications
Additional query words: XL2001 XL98 XL97 8.00 adjacent contiguous nonadjacent noncontiguous discontiguous discontinuous maximum minimum greatest least
Keywords: kbhowto kbprogramming KB139574