Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Finding the Address of the Lowest Value in a Range.

Finding the Address of the Lowest Value in a Range

Written by Allen Wyatt (last updated April 24, 2021)
This tip applies to Excel 97, 2000, 2002, and 2003


When writing a macro, you can find the lowest value in a range of cells by using the WorksheetFunction method to apply the MIN worksheet function. You may need, however, to not only find the lowest value in the range, but also the address of the first cell that contains that value.

One simple way is to simply step through the range you want to examine and derive both the lowest value and the address of the cell being examined, as in the following:

Function FindLowestAddr(pRng As Range) As String
    Application.Volatile
    MinVal = pRng.Cells(1).Value
    MinAddr = pRng.Cells(1).Address
    For Each c in pRng
        If c.Value < MinVal Then
            MinVal = c.Value
            MinAddr = c.Address
        End If
    Next c
    FindLowestAddr = MinAddr
End Function

Note that this approach doesn't rely upon the MIN worksheet function at all. There is a drawback to it, however—it doesn't differentiate between cells that contain numeric values and those that don't. In other words, if the range passed to the function contains a blank cell, that cell is considered to contain a zero value, which may very well be the lowest value in the range.

One way around this is to rely upon worksheet functions from within the macro. The following macro uses both the MIN and MATCH worksheet functions to determine the location of the minimum value and then the index (offset) of that cell within the range.

Function GetAddr(rng As Range) As String
    Dim dMin As Double
    Dim lIndex As Long
    Dim sAddress As String

    Application.Volatile
    With Application.WorksheetFunction
        dMin = .Min(rng)
        lIndex = .Match(dMin, rng, 0)
    End With
    GetAddr = rng.Cells(lIndex).Address
End Function

It should be noted that if you are using the macro only to discover the address because you figured there was no way to derive the desired information without the macro, then you can do away with the macro entirely by using a worksheet formula. For instance, if you want to determine the address of the lowest-valued cell in the named range MyRange, you could use the following:

=ADDRESS(ROW(MyRange)+MATCH(MIN(MyRange),MyRange,0)-1,COLUMN(MyRange))

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7140) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Finding the Address of the Lowest Value in a Range.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Changing Compression Print Resolution

The resolution at which Word compresses graphics in a document may be bothersome. If it is, your options are very ...

Discover More

Self-Aware Macros

Sometimes it may be helpful for a macro to know exactly where it is being executed. This tip provides a way that you can ...

Discover More

Multiple References to an Endnote

Adding endnotes in a document is easy in Word. If you want to create multiple references to a single endnote, you can do ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (menu)

Stopping a Formula from Updating References

Insert or delete a column, and Excel automatically updates references within formulas that are affected by the change. If ...

Discover More

Extracting a Pattern from within Text

If you have a large amount of data in a worksheet and you want to extract information from the text that meets certain ...

Discover More

Determining "Highest Since" or "Lowest Since"

When compiling statistics on a collection of data points, you may want to know whether a particular value is the "highest ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is six minus 4?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.