"Trace dependents" on several cells *at once*

Alejo1970

New Member
Joined
Jul 10, 2007
Messages
19
Is it possible to use the "Trace dependents" functionality in several cells *at once*? You can do it for an individual cell.

However, many times I find myself reviewing a spreadsheet developed by someone else, and I want to determine whether *any* cell from a *range* of cells has any dependents.

Same goes for tracing precedents.

Anyone know of a way of how to do this without macros?

Thanks!


-Alejandro
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I looked into non-macro ways to do this without success.

I worked on something similar but not identical. If you know macros you could modify my code.

What I did was a I searched an entire workbook. On each worksheet I identified how many cells had dependencies located on another worksheet. I then created a new worksheet call "Dependents" which listed each worksheet in one column and the number of cells in that worksheet with off-sheet dependencies.

Thus, any worksheet with zero off-sheet dependencies is either a reduntant input sheet or an output sheet, and can be deleted with no effect on the main model. Sheets with a very low dependency number may be mostly reduntant and could be cleaned up and then deleted. This would have to be iterated as sheets that formerly fed only into reduntant sheets (eg part of a reduntant pathway) would, after the first round of deletions, then start returning zeros and have to be deleted themselves.

Not sure if this helps, I'm sure with some modification you could get the main driver of this code to identify all dependencies within a range instead of a within an entire workbook.

Code:

Code:
Sub OffSheetDependentCount()
  
'Add new sheet "Dependents" at start of workbook and formats the sheet
    Application.DisplayAlerts = False
    On Error Resume Next
    Sheets("Dependents").Delete
    Application.DisplayAlerts = True
    On Error GoTo 0
    Sheets.Add().Name = "Dependents"
    ActiveSheet.Move Before:=ActiveWorkbook.Sheets(1)
    ActiveWindow.DisplayGridlines = False
    ActiveWindow.Zoom = 70
    ActiveSheet.Cells(2, 2) = "Sheet Name"
    ActiveSheet.Cells(2, 3) = "Number of off-sheet dependencies"
    Columns("A:D").Select
    Selection.ColumnWidth = 30
    Range("B2:C2").Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
    End With
    With Selection.Font
        .FontStyle = "Bold"
        .ColorIndex = 2
    End With
    With Selection.Interior
        .ColorIndex = 50
    End With
    Range("B2:C2").Select
    Selection.Borders(xlLeft).LineStyle = xlContinuous
    Selection.Borders(xlRight).LineStyle = xlContinuous
    Selection.Borders(xlTop).LineStyle = xlContinuous
    Selection.Borders(xlBottom).LineStyle = xlContinuous
    Rows("2:2").EntireRow.AutoFit
'Cycle through sheets, rows and columns
    Dim DependentCount As Long
    
    For ws = 2 To ActiveWorkbook.Worksheets.Count
        
        DependentCount = 0 'each worksheet starts with zero off-sheet dependents
        For r = 1 To Worksheets(ws).UsedRange.Rows.Count
        
            For c = 1 To Worksheets(ws).UsedRange.Columns.Count
                
                Worksheets(ws).Activate
                Cells(r, c).Select
                Selection.ShowDependents
                          
'Identifies if cell has at least one dependency on another sheet
                          
                Worksheets(ws).Cells(r, c).NavigateArrow TowardPrecedent:=False, ArrowNumber:=1, LinkNumber:=1
                    
                If ActiveCell.Worksheet.Name <> Worksheets(ws).Cells(r, c).Worksheet.Name Then
                    
'If so, adds the count of one to total dependents on the worksheet
                    
                    DependentCount = DependentCount + 1
                    
                End If
                
            Next c
        
        Next r
        
'Add # of Dependent cells on this sheet to your new "Dependents" sheet
        Worksheets(ws).ClearArrows
        Worksheets("Dependents").Cells(ws + 1, 2) = Worksheets(ws).Cells(1, 1).Worksheet.Name
        Worksheets("Dependents").Cells(ws + 1, 3) = DependentCount
                
    Next ws
Worksheets("Dependents").Activate
Cells(1, 1).Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,655
Members
448,975
Latest member
sweeberry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top