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: Counting Precedents and Dependents.
Written by Allen Wyatt (last updated May 24, 2021)
This tip applies to Excel 97, 2000, 2002, and 2003
Because Excel allows you to create formulas that refer to other cells, it stands to reason that cells can be dependent on each other. In fact, Excel has two technical terms that are used to define the relationship between cells: precedents and dependents.
Precedents are those cells on which a formula is based. Thus, if cell A5 contains the formula =A3 + A4, then both A3 and A4 are precedents for cell A5. Dependents are the reverse of precedents. Thus, in this example, cell A5 is a dependent of cells A3 and A4. You can use the auditing tools in Excel to graphically depict these relationships between cells, as described in other issues of ExcelTips.
What if you want to know how many dependents and precedents there are in a worksheet, however? There is no Excel command that displays this information. You can use a macro to calculate and display this information, however. The following macro will do just that:
Sub CountDependentsPrecedents() Dim ws As Worksheet Dim lDep As Long Dim lPre As Long On Error GoTo err For Each ws In Worksheets ws.Select lDep = 0 lPre = 0 lDep = Range("a1:iv65536").Dependents.Count lPre = Range("a1:iv65536").Precedents.Count MsgBox "Worksheet: " & ActiveSheet.Name & vbCr & _ "Dependents: " & lDep & vbCr & _ "Precedents: " & lPre Next ws Exit Sub err: Resume Next End Sub
When you run this macro, it steps through each worksheet in your workbook and displays the number of dependents and precedents in each.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2015) 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: Counting Precedents and Dependents.
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!
Excel provides some great tools that can help you see the relationships between the formulas in your worksheets. These ...
Discover MoreCells that use the information in a particular cell are called dependent cells. Excel provides auditing tools that allow ...
Discover MoreCells that affect another cell are called precedent cells. If you need to know which cells affect a particular cell, ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments