Function oneCellsDependents(ByVal inRange As Range, Optional doPrecedents As Boolean) As String
Dim inAddress As String, returnSelection As Range
Dim i As Long, pCount As Long, qCount As Long
Rem remember selection
Set returnSelection = Selection
inAddress = fullAddress(inRange)
Application.ScreenUpdating = False
With inRange
.ShowPrecedents
.ShowDependents
.NavigateArrow doPrecedents, 1
Do Until fullAddress(ActiveCell) = inAddress
pCount = pCount + 1
.NavigateArrow doPrecedents, pCount
If ActiveSheet.Name <> returnSelection.Parent.Name Then
Do
qCount = qCount + 1
.NavigateArrow doPrecedents, pCount, qCount
oneCellsDependents = oneCellsDependents & fullAddress(Selection) & Chr(13)
On Error Resume Next
.NavigateArrow doPrecedents, pCount, qCount + 1
Loop Until Err.Number <> 0
.NavigateArrow doPrecedents, pCount + 1
Else
oneCellsDependents = oneCellsDependents & fullAddress(Selection) & Chr(13)
.NavigateArrow doPrecedents, pCount + 1
End If
Loop
oneCellsDependents = inAddress & " has " & pCount + Application.WorksheetFunction.Max(0, qCount - 1) _
& IIf(doPrecedents, ' precedent range(s).', ' dependent range(s).') & vbCrLf & oneCellsDependents
.Parent.ClearArrows
End With
Rem return selection to where it was
With returnSelection
.Parent.Activate
.Select
End With
End Function