Highlighting an Unchanging Value

Written by Allen Wyatt (last updated September 18, 2025)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365


Bonnie has a worksheet used to accumulate data from testing equipment. Readings from the equipment are added to the bottom of column A daily. In cell D4 Bonnie has a formula that calculates the average of the last 14 readings contained in column A. She wonders if there is a way to highlight cell D4 or flag the value it contains if the average hasn't changed over the past week.

There are a couple of ways this could be handled. The key is to understand that the only way to make this determination is to keep track of 7 14-day averages, one for each day of the past week. This can obviously only be done if you can change the layout of your worksheet so that D4 is only the most recent 14-day average. Perhaps, in cells D5:D10 you could place the 14-day averages for each of the preceding 6 days.

As an example, let's say that you are using Excel 365 and generating the current 14-day average, stored in cell D4, with the following formula:

=AVERAGE(TAKE(TRIMRANGE(A:A,2),-14))

In cell D5 you want the 14-day average for the period ending on the previous day, so you would add the DROP function to the formula, in this manner:

=AVERAGE(TAKE(DROP(TRIMRANGE(A:A,2),-1),-14))

The key here is that you are specifying, through the -1 parameter, that the last day's reading be dropped from the range of cells being considered. Thus, in cells D6, D7, D8, D9, and D10 you could use parameters of -2, -3, -4, -5, and -6. What you end up with in the range D4:D10 is the last 7 days of 14-day averages. You can then easily compare these to see if they are the same, or you can use a conditional formatting rule to highlight the cells if they are not equal.

If you are not using Excel 365, you may be better off using a macro to do the necessary calculations. Assuming that the data in column A contains no blank cells, you can use the following formula for your latest average in cell D4:

=AVERAGE(OFFSET(A1, COUNTA(A:A) - 14, 0, 14))

The following macro will perform this same formula on your A:A data, but also look at the previous six days' averages:

Function SameAvgs() As Boolean
    Const EVAL1 = "AVERAGE(OFFSET(A1, COUNTA(A:A) - "
    Const EVAL2 = ", 0, 14))"
    Dim n As Integer
    Dim xAvg As Double

    Application.Volatile

    ' Default return is that the averages are the same
    SameAvgs = True

    ' Calculate the 14-day average for today
    xAvg = Evaluate(EVAL1 & 14 & EVAL2)

    ' Step through the averages for the previous 6 days
    For n = 1 To 6
        If xAvg <> Evaluate(EVAL1 & (14 + n) & EVAL2) Then
            ' Averages are not the same
            SameAvgs = False
        End If
    Next n
End Function

The function returns True or False, depending on whether the 7 days of averages are the same or not. You can put this formula in its own cell (perhaps E4) in order to flag the value, as Bonnie wants:

=IF(SameAvgs(),"No Change in 7 Days!","")

You could also use the function in a conditional formatting rule to highlight cell D4 if the function returns True, meaning that there has been no change in the average over the 7-day period.

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 (13957) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365.

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

Comments Don't Appear when Cell is Pointed To

One way that you can view comments in a worksheet is to have them appear when you hover the mouse pointer over a cell. If ...

Discover More

Enforcing a Desired Font

If your workbooks are shared and used by a number of different people, you may end up with some formatting in those ...

Discover More

Using an Input Mask

When you are entering information in a worksheet, it sure would be handy to have a way to "mask" the information being ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Using Named Formulas Across Workbooks

You can use the naming capabilities of Excel to name both ranges and formulas. Accessing that named information in a ...

Discover More

Address of a Cell in Which a Threshold is Exceeded

If you keep a lot of data in Excel, you may be interested in figuring out when that data surpasses a threshold. This tip ...

Discover More

Indirectly Referencing a Cell on a Different Worksheet

Excel includes the powerful INDIRECT function which can be used to assemble references to other cells in your workbook. ...

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 seven more than 7?

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.