ShowDependents/NavigateArrow only returns 1 cell from another sheet

Amateurhr

Active Member
Joined
Dec 26, 2011
Messages
343
The code below returns only ONE dependent from another sheet (even though there are multiple dependents on other sheets), and returns rngPrecedent's address (the cell we're investigating) multiple times.

I simplified this post from another one as I narrowed down the issue to be the specific line in red

Rich (BB code):
Sub FindDependents(ByVal rngPrecedent As range)

    Dim dependentCell As range
    Dim arrowNumber As Integer

    'We'll be checking for errors as we go
    On Error Resume Next
       
    'Show the dependency arrows
    rngPrecedent.parent.ClearArrows
    rngPrecedent.ShowDependents
    arrowNumber = 1
   
    'We'll break out of this loop when no more dependencies are found.
    Do
        Set dependentCell = rngPrecedent.NavigateArrow(False, arrowNumber, 1)
        If Err.Number <> 0 Then
            GoTo NoMoreArrows
        Else
            keyStr = dependentCell.parent.name & "!" & dependentCell.Address
            arrowNumber = arrowNumber + 1
        End If
    Loop While not dependentCell is nothing
   
NoMoreArrows:
    Exit Sub

End Sub
 
Last edited by a moderator:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I just caught my error, I had the arrowNumber incrementing in the wrong location. I should have this instead:

Code:
Set dependentCell = rngPrecedent.NavigateArrow(False, 1, arrowNumber)
 
Upvote 0

Forum statistics

Threads
1,207,261
Messages
6,077,356
Members
446,279
Latest member
hoangquan2310

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