Solved

return max. value from a range...

Posted on 2014-04-20
4
190 Views
Last Modified: 2014-04-20
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
Comment
Question by:Mike Eghtebas
  • 2
  • 2
4 Comments
 
LVL 22

Expert Comment

by:Flyster
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

by:Mike Eghtebas
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

by:
Flyster earned 500 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

by:Mike Eghtebas
ID: 40011990
Thank you.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

735 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