LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Checking cell for Dependents


Better question for you Robin. I am using the code below to call you
function on a cell in that I call StartCell. I have created dependent
in the same sheet and several other sheets in my workbook. The cod
below will actually select each depent cell. However you will notic
that I am using a For Each loop (1 to 1000000). I could not figure ou
how to use a For Each loop with NavigateArrows. I also assumed that
could limit the loop by putting a On Error stmt in so that when i
tried to navigate an error that does not exist it would create an erro
and exit the loop. This is not working.

Now this is actually overkill, because all I really want to do i
identify WHEN a navigation arrow takes me to a sheet other than th
sheet that the cell is in. How do I trap the event that takes me t
another sheet? I don't really care where it goes, but I do care IF i
goes. Thanks

Sub Thing()
Dim Cell As Range
Dim HasDep As Boolean
Dim CountDep As Integer
Dim X As Double

Set Cell = Range("StartCell")

HasDep = HasInternalDependents(Cell)

If HasDep = True Then
Cell.ShowDependents
End If

For X = 1 To 1000000
On Error Resume Next
Cell.NavigateArrow True, 1
ActiveCell.NavigateArrow TowardPrecedent:=False, ArrowNumber:=X, _
LinkNumber:=1
On Error GoTo 0
Next X

End Sub

Public Function HasInternalDependents(rngTest As Range) As Boolean
Dim rngCell As Range
Dim rngDep As Range

For Each rngCell In rngTest
Set rngDep = Nothing
On Error Resume Next
Set rngDep = rngCell.Dependents
On Error GoTo 0
If Not rngDep Is Nothing Then
HasInternalDependents = True
Exit Function
End If
Next rngCell
End Functio

--
ExcelMonke
-----------------------------------------------------------------------
ExcelMonkey's Profile: http://www.excelforum.com/member.php...nfo&userid=522
View this thread: http://www.excelforum.com/showthread.php?threadid=27618

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you ID cell precendents/dependents in other sheets? [email protected] New Users to Excel 2 October 4th 07 09:31 AM
Spell Checking with checking cell notes jfitzpat Excel Discussion (Misc queries) 0 August 8th 07 10:26 PM
How to trace dependents in a book at once without checking cell by alisfalor Links and Linking in Excel 2 March 11th 05 07:53 AM
Checking cell for Dependents ExcelMonkey[_184_] Excel Programming 0 November 13th 04 11:13 AM
Checking cell for Dependents ExcelMonkey[_182_] Excel Programming 1 November 10th 04 01:02 AM


All times are GMT +1. The time now is 09:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"