Leaving Trace Precedents Turned On

Written by Allen Wyatt (last updated May 31, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


1

Gavin has a large worksheet that he works with, and he finds it helpful to use the Trace Precedents tool (on the Formulas tab of the ribbon) to figure out what is going on. Gavin would like the setting of the tool to be "turned on" even when he saves the workbook, but Excel doesn't let him do this. He wonders if there is a way to leave it turned on so that the precedents are always marked in the workbook.

One would think that it should be relatively easy to turn on the precedents, via macro, when you open a workbook. All you need to do is use a macro like the following:

Sub ShowTracePrecendents1()
    Dim rng As Range
    Dim c As Range

    With ActiveSheet.UsedRange
        Set rng = .Cells.SpecialCells(xlCellTypeFormulas, 23)
    End With
    Application.ScreenUpdating = False

    For Each c In rng
        c.ShowPrecedents
     Next
End Sub

The macro determines which cells in the worksheet contain formulas (only formula-containing cells can have precedents) and then steps through each of those cells, turning on the display of the precedents.

The problem, of course, is that this approach doesn't do exactly what Gavin wanted. It is probable that Gavin, when working with his data, doesn't turn on the precedents for every single cell, but only for some of the cells. The macro turns on precedent display for all possible cells in the worksheet. If you only want to display the precedents for some cells, you need to specify the cells in the macro.

Sub ShowTracePrecendents2()
    Dim rng As Range
    Dim c As Range

    Set rng = Range("G1:G5,G7:G8")
    For Each c In rng
        c.ShowPrecedents
    Next
End Sub

In order to use the macro effectively, you would need to change the line that sets the rng variable so that it references the cells for which you want precedents displayed.

Regardless of which macro you go with, you can create an "auto open" macro (as discussed in other ExcelTips) that will run it automatically whenever the workbook is opened.

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 (13161) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 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

Counting Values within 10% of a Target

If you need to count the number of values that fall between a lower and upper value, then you can use a number of ...

Discover More

Understanding Custom Chart Templates

Excel allows you to create custom chart formats that go beyond the standard formats provided in the program. These custom ...

Discover More

Selecting a Graphic that is Behind Text

Position a graphic so that it is "behind" your text, and it may seem like you can no longer select the graphic. Here's ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Non-Printing Controls

Don't want your form controls to print out with your worksheet? Here's how to make sure that Excel excludes them from ...

Discover More

Using Multiple Print Settings

Do you have a worksheet from which you need to print only portions of the data available? There are two ways you can ...

Discover More

Using Subtotals and Totals

You can insert subtotals and totals in your worksheets by using either a formula or specialized tools. This tip explains ...

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

2020-12-02 02:03:37

John Bentley

And additional tip (which may be obvious for experienced Excel users) ...

In order to quickly fetch the values for Range() in ShowTracePrecendents2(): click in any blank cell and type "=", then hold ctrl while you click the desired cells (including cell ranges if desired). Copy the values entered after the "=".

Anyway thanks Allen for ShowTracePrecendents2(). That elegantly solves the problem!


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.