Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier 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 October 9, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


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. Display the Excel Options dialog box. (In Excel 2007 click the Office button and then click Excel Options. In Excel 2010 and later versions display the File tab of the ribbon and then click Options.)
  2. Click Formulas at the left side of the dialog box. (See Figure 1.)
  3. Figure 1. The Formulas options in the Excel Options dialog box.

  4. Make sure the Enable Iterative Calculation 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 (10916) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel 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

Saving Portions of Files

Want to save snippets from a document into individual files? There are a couple of easy ways to achieve this goal, as ...

Discover More

Saving a Document as a Web Page

Want to save your document as a Web page? It's easy to do in Word; almost as easy as saving your document normally.

Discover More

Removing Duplicates in Word

If you have information in Word such as e-mail addresses or part numbers, your document might include duplicates. This ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

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

Incrementing Numeric Portions of Serial Numbers

If you use serial numbers that include both letters and numbers, you might wonder how you can increment the numeric ...

Discover More

Adjusting Test Scores Proportionately

Teachers often grade on what is affectionately referred to as "the curve." The problem is, it can be a bit difficult to ...

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 five more than 3?

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 ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu 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.