View Single Post
  #5   Report Post  
Harlan Grove
 
Posts: n/a
Default

Gary''s Student wrote...
For the first part, enter the following UDF:

Function whereis(r As Range, v As Variant) As String
Dim rr As Range
For Each rr In r
If rr.Value = v Then
whereis = rr.Address
End If
Next
End Function

and use it like
=whereis(A:A,MAX(A:A))

where A:A can be replaced by your range.


Using a different syntatic form than existing functions, e.g., FIND and
MATCH, in which the value sought comes first followed by the range or
array in which to search, is at best questionable.

Also, your udf returns the last matching value in the range rather than
the first when there are multiple entries. Maybe that's OK, maybe not,
but you should have mentioned that.

But using a udf for something that could be done by a few built-in
functions is a bad idea. In order to use udfs, users may need to change
macro security settings, and udfs are SLOW. The address of the topmost
MAX value is given by

=CELL("Address",INDEX(A:A,MATCH(MAX(A:A),A:A,0))

4 built-in functions are guaranteed to recalc faster than a udf and a
built-in function call.