Highlighting an Unchanging Value

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


2

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

Selecting Text in Linked Text Boxes

Text boxes are often used as design elements in a document layout. If you have linked text boxes, you may have noticed ...

Discover More

Missing Fonts in a Letterhead

When you create a document (such as a letterhead) that you want multiple people to use, you need to be concerned with ...

Discover More

Replacing Characters at the End of a Cell

The Find and Replace capabilities of Excel can come in handy, but they can't accomplish all your replacement needs. One ...

Discover More

Program Successfully in Excel! This guide will provide you with all the information you need to automate any task in Excel and save time and effort. Learn how to extend Excel's functionality with VBA to create solutions not possible with the standard features. Includes latest information for Excel 2024 and Microsoft 365. Check out Mastering Excel VBA Programming today!

More ExcelTips (ribbon)

Finding the Directory Name

Need to know the directory (folder) in which a workbook was saved? You can create a formula that will return this ...

Discover More

Generating Numeric Testing Data

Excel can be used to generate random testing data that you can use in any way you deem necessary. This tip provides ...

Discover More

Summing Based on Formatting in Adjacent Cells

It is easy to use Excel functions to sum values based on criteria you establish, unless those criteria involve the ...

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 7 - 4?

2025-09-21 17:06:10

J. Woolley

TRIMRANGE(A:A, 2) is an Excel 365 function that returns the range A:A down to and including the last non-blank cell; empty cells after the last non-blank cell are not included (trimmed). But Excel 365 also includes the dot operator (.) that trims a range when used with the colon operator (:), so A:.A returns the same result.
COUNTA(A:A) returns the row number of the last data value in column A, but only if "the data in column A contains no blank cells" (beginning with cell A1) and all cells after the last data value are empty.
Therefore, these 3 expressions return the same result, but the first 2 currently require Excel 365:
TAKE(TRIMRANGE(A:A, 2), -14)
TAKE(A:.A, -14)
OFFSET(A1, COUNTA(A:A) - 14, 0, 14)


2025-09-20 10:38:44

J. Woolley

Re. Function SameAvgs(), I suggest adding 'Exit Function' before 'End If'.
But here's another way (which also avoids Application.Volatile):

Function SameAvgs(xAvg As Double) As Boolean
    Const EVAL1 = "AVERAGE(OFFSET(A1, COUNTA(A:A) - "
    Const EVAL2 = ", 0, 14))"
    Dim n As Integer
    SameAvgs = False
    For n = 1 To 6
        If xAvg <> Evaluate(EVAL1 & (14 + n) & EVAL2) Then Exit Function
    Next n
    SameAvgs = True
End Function

Then use this formula:

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


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.