• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

return max. value from a range...

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
Mike Eghtebas
Asked:
Mike Eghtebas
  • 2
  • 2
1 Solution
 
FlysterCommented:
Try something like this:

Public Function fnRangeMax(strRangeName As String)

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

Flyster
0
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
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
 
FlysterCommented:
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
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Thank you.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now