Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# return max. value from a range...

Posted on 2014-04-20
Medium Priority
194 Views
There is a named-range (R_01) representing the following cells:

Formulas!\$D\$1:\$AA\$2

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.
0
Question by:Mike Eghtebas
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 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

Flyster
0

LVL 34

Author Comment

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

=Max(Range("R_01"))

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

Mike
0

LVL 22

Accepted Solution

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

=MAX(\$D\$1:\$AA\$2)

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
0

LVL 34

Author Closing Comment

ID: 40011990
Thank you.
0

## Featured Post

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 will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
###### Suggested Courses
Course of the Month11 days, 11 hours left to enroll