Mala (Computer) Aug 23, 2001
Tigrek, sorry I'm a bit late.
When limits are indefinite, it's a good idea to set up loops with preposterously high upper-bounds and sit back comfortably while the VBA 'On Error Resume Next' statement handles things - may not be very elegant, but gets the work done:
To test the code for your problem I did the following:
1. Created a formula in cell F6 on a sheet (can be any cell, but the code below refers to this - the cell has been named 'TestRng').
2. This formula had ALL sorts of references - same worksheet, other worksheets in same workbook AND other Workbooks.
Taking off from your code, I wrote the following Sub:
Sub MyPrecedents()
RoOff = -1
Set TestRng = Range("TestRng"

Application.Goto Reference:=TestRng, Scroll:=True
TestRng.ShowPrecedents
For Arr = 1 To 20
For Lnk = 1 To 20
On Error Resume Next
Application.Goto Reference:=TestRng, Scroll:=True
Set PrecRng = TestRng.NavigateArrow(True, Arr, Lnk)
If Err = 0 Then
KK = PrecRng.Address(External:=True)
MatchFound = 0
MatchFound = WorksheetFunction.Match(KK, Columns("G"

.Cells, 0)
If MatchFound = 0 Then
RoOff = RoOff + 1
TestRng.Offset(RoOff, 1) = KK
End If
End If
Next
Next
End Sub
Note that I set Arr to 20 and Lnk per Arr to 20 - Nobody in their right mind would write such a long formula - so it's a safe bet it'll cover ALL references.
The references are 'dumped' in the col. beside TestRng starting from TestRng.Row
To modify for Dependents, modify the statement:
Set PrecRng = TestRng.NavigateArrow(True, Arr, Lnk)
and
TestRng.Offset(RoOff, 1) = KK
TO
Set DepRng = TestRng.NavigateArrow(False, Arr, Lnk)
+ all refs to PrecRng to DepRng
and
TestRng.Offset(RoOff, 2) = KK to get the refs in the next col.
Of course, u'll have to modify the code to suit the way your worksheet is set up.
By the way, this was a good one - and the most satisfying part is the real effort you'd put in before posting the query on the forum.
Good Luck!