ShowDependents Method works inconsistently?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Goal: To show all dependents of a range of cells.

Problem: The code (see below) works sporatically and is therefore useless. For some groups of cells it will work perfectly, showing all dependents. In other cases, it will show only the dependents of the initially active cell. Will someone smarter than me please tell me what the heck is going on?!? (If it matters, I am using Excel 2002.)

Sub Showem_all()
' Show all dependencies for selected region of cells.
x = ActiveCell.CurrentRegion.Columns.Count
y = ActiveCell.CurrentRegion.Rows.Count
For i = 1 To x
For j = 1 To y
ActiveCell.Offset(i - 1, j - 1).Range("A1").ShowDependents
Next j
Next i
End Sub
 
You code assumes that the active cell will always be the top, leftmost cell
in the current region, which may or may not be true. I don't know if that
is your intent but if what you really want to do is to show the dependents
of the current region, regardless of where the active cell is in the current
region, you might try this:

Sub DepsOfCurrRegion()
Dim Cell As Range
For Each Cell In ActiveCell.CurrentRegion
Cell.ShowDependents
Next
End Sub
 
Back
Top