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
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
  • Learn & ask questions
  • 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 34

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 34

Author Closing Comment

by:Mike Eghtebas
ID: 40011990
Thank you.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

752 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