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: Only Showing the Maximum of Multiple Iterations.

Only Showing the Maximum of Multiple Iterations

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


Mike has three cells (A1:A3) that show results of calculations. He needs a way to determine the maximum value that has ever appeared in any of these cells, and have that value stored in cell E5. He knows how to get the maximum out of the three, but when he recalculates the worksheet, if the values in A1:A3 are less than the maximum value in E5 (based on previous determinations of the maximum in A1:A3), then E5 should not change. In other words, E5 should only change if whatever is in A1:A3 is greater than what is in E5. Mike isn't sure how to perform such a calculation.

There are two ways you can solve this issue. The first is to create a simple formula that would be placed in cell E5:

=MAX(A1:A3,E5)

The MAX function examines the various values it references and then returns the maximum out of them—exactly what is wanted. However, since this formula is being placed in cell E5 and it also references E5, it will return an error. This is because the formula creates a circular reference. Excel can handle those, but you need to make a small configuration change to do it:

  1. Choose Options from the Tools menu. Excel displays the Options dialog box.
  2. Display the Calculation tab. (See Figure 1.)
  3. Figure 1. The Calculation tab of the Options dialog box.

  4. Make sure the Iteration check box is selected.
  5. Click OK.

Now Excel will handle circular references, such as the simple formula you've put in cell E5.

The second approach is to use a macro to perform the calculation. This approach may be preferred because you may not want (for some reason) to enable circular references in your workbook. The following is actually an event handler, added to the code for the worksheet. (Easiest method: Right-click on the sheet tab, display the code window from the resulting Context menu, and add the macro to that code window.)

Private Sub Worksheet_Calculate()
    Dim dMax As Double
    dMax = Application.WorksheetFunction.Max(Range("A1:A3"))
    If dMax > Range("E5") Then
        Application.EnableEvents = False
        Range("E5") = dMax
        Application.EnableEvents = True
    End If
End Sub

The macro is triggered every time the worksheet is recalculated. It grabs the maximum of A1:A3 and compares it to what is in E5. Only if it is larger is that value then placed into E5.

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 (10915) 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: Only Showing the Maximum of Multiple Iterations.

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

Printing Comments

After adding comments to a document you may want to print them later. Word provides a variety of ways you can print the ...

Discover More

Making All Occurrences Bold

Want to make instances of a given word or phrase bold throughout a worksheet? Here's a way you can make the change quickly.

Discover More

Sharing Headings with Others

Headings form the outline of your document and hopefully give it an easy-to-follow organization. If you want to share ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (menu)

Starting Out Formulas

When you enter a formula from the keyboard, Excel only knows it is a formula if you start it with an equal sign. You can ...

Discover More

Automatically Numbering Rows

Adding row numbers to a column of your worksheet is easy; you just need to use a formula to do it. Here's a quick look at ...

Discover More

Determining Winners, by Category

Do you need to determine the top three values in a range of columns? The techniques discussed in this tip will come in ...

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 8 - 5?

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.