return max. value from a range...

Posted on 2014-04-20
Last Modified: 2014-04-20
There is a named-range (R_01) representing the following cells:


Question: How can I detect the max. value in this range?

MsgBox fnRangeMax("R_01")

Public Function fnRangeMax(strRangeName As String)

   fnRangeMax = <how to look through this R_01 and return the max. value it has?>
End Function

Thank you.
Question by:Mike Eghtebas
  • 2
  • 2
LVL 22

Expert Comment

ID: 40011944
Try something like this:

Public Function fnRangeMax(strRangeName As String)

Set rg = Range("R_01")
 fnRangeMax = Application.Max(rg)
End Function

LVL 33

Author Comment

by:Mike Eghtebas
ID: 40011978
Can I also enter this a formula into a cell?


I tired this it didn't work. Any idea how this would work if possible at all?

LVL 22

Accepted Solution

Flyster earned 500 total points
ID: 40011989
If you want a formula for the cell, use:


This macro also works:

Sub FindMax()
Dim msg As String

Set rg = Range("R_01")
 fnRangeMax = Application.Max(rg)
 msg = MsgBox("The Max Value is " & fnRangeMax, vbInformation)

End Sub
LVL 33

Author Closing Comment

by:Mike Eghtebas
ID: 40011990
Thank you.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now