Loading
Excel.Tips.Net ExcelTips (Menu Interface)

Accessing Dependent and Precedent Information

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: Accessing Dependent and Precedent Information.

David rightly notes that Excel provides auditing tools (Trace Dependents and Trace Precedents) that are a very helpful way of keeping track of what is happening in large worksheets. However, the actual interface just lists out the cells in a small area, and David cannot easily copy out this list of cells to analyze and manipulate it. When he uses Trace Dependents on an important cell in a large worksheet, the small dialog box can contain several hundred references. David wonders if there is a relatively easy way of getting this information into a more usable format, like a blank worksheet or another workbook.

There is obviously no way to do this with native Excel commands, but you can create a macro that will extract the information you desire. The following macro will list the dependent cells for whatever cell is selected when you run the macro:

Sub ListDependents()
    Dim rArea As Range
    Dim rCell As Range
    Dim sActiveCell As String
    Dim rDep As Range
    Dim lRow As Long

    On Error Resume Next
    Set rDep = ActiveCell.Dependents
    If rDep Is Nothing Then
        MsgBox ActiveCell.Address(False, False) & _
          " has no dependents"
        Exit Sub
    End If

    On Error GoTo 0
    sActiveCell = ActiveCell.Address(False, False)
    Worksheets.Add
    lRow = 1
    Cells(lRow, 1).Value = "Dependents for " & sActiveCell
    For Each rArea In rDep
        For Each rCell In rArea
            lRow = lRow + 1
            Cells(lRow, 1) = rCell.Address(False, False)
        Next
    Next
    Set rArea = Nothing
    Set rCell = Nothing
    Set rDep = Nothing
End Sub 

When the macro is first run, it checks to see if there are any dependents for the cell. If there aren't, then you are notified and the macro is exited. If there are dependents, then a new worksheet is added to the workbook and the dependents of the cell are added to the worksheet.

If you want the macro to instead list precedents, all you need to do is change the all instances of "Dependents" in the macro to "Precedents."

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3121) 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: Accessing Dependent and Precedent Information.

Related Tips:

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

 

Leave your own comment:

*Name:
Email:
  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*Text:
*What is 5+3 (To prevent automated submissions and spam.)
 
 
           Commenting Terms

Comments for this tip:

Brian    28 May 2016, 14:06
It seems that
 Set rDep = ActiveCell.Dependents
    If rDep Is Nothing Then
only works if there are no dependents on the active sheet.

If the cell is only referenced on other sheet(s), rdep is still nothing, and the cell is cited as having no dependents.

How would you remedy?
Regards
Brian
Vinod    27 Jul 2013, 09:31
it will be all the more useful, if the name of teh dependent cell in addition to its address is also given.
 
 

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

 

Advertise with Us

Our Privacy Policy

Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives

 

Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2016 Sharon Parq Associates, Inc.