address of min or max result

  • Thread starter Thread starter Gary Keramidas
  • Start date Start date
G

Gary Keramidas

is there an easy way to return the address of the min or max result? if it's a
lot of code, i'm not going to worry about it, it's not that important. but if
there's an easy way, i'd like to know.

thanks
 
Gary

=MATCH(MAX(A:A),A:A,0)

will return the row number of the maximum value in column A

=MATCH(MIN(A:A),A:A,0) for the minimum

Regards

Trevor
 
thanks, both of you, ended up getting this from your help.

application.worksheetfunction.match(application.worksheetfunction.max(range("c23:k23")),range("c23:k23"),0)
 
Thanks for the feedback.

The code gives the position within the data range. If you need the
"address" or the column you'll need to adjust the result.

Any likelihood that you'll have duplicate maximum or minimum values ? The
match will only return the first occurrence.

Regards

Trevor
 
you may like this better

maxaddress = Columns(1).find(Application.Max(Columns(1))).Address

change to your range if desired
Sub findmax()
Set myrange = Range("c23:k23")'or rows(23)
mc = myrange.find(Application.Max(myrange)).Address
MsgBox mc
End Sub
 
hi don:

i get an object variable or with block variable not set error when i run it.
 
In the case of looking in ONE row, try this

ma = Rows(23).find(Application.Max(Rows(23))).Address
MsgBox ma
 
Find seems sensitive to format when working with decimal values. Your
problem is that find isn't finding a match and raising the error. Probably
better to use Match as previously suggested.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top