I always forget both cell.Precedents and also cell.DirectPrecedents only
return precedents on the same sheet as 'cell'. This might be a bit better
but note the caveat in the comments, could further parse the formula to
decrease the possibility of returning a false positive.
Function CellHasPrecs(cell As Range) As Boolean
Dim rDirPrecs As Range
If cell.HasFormula Then
On Error Resume Next
Set rDirPrecs = cell.DirectPrecedents
On Error GoTo 0
If Not rDirPrecs Is Nothing Then
CellHasPrecs = True
ElseIf InStr(cell.Formula, "!") > 0 Then
' formula contains an ! strongly indicates a ref to
' to another sheet but not 100% conclusive
CellHasPrecs = True
End If
End If
You can either use the .Dependents property, but as Peter said, this only
works with references within the sheet,
or you can use .ShowDependents followed by .NavigateArrow, which will
include off-sheet dependents.
warning: .showDependents and .NavigateArrow are a bit slow, if performance
is an issue look at only doing it once for similar blocks of formulae (use
R1C1 mode to find similar formulae).
regards
Charles
__________________________________________________
Outlines for my Sessions at the Australia Excel Users Group http://www.decisionmodels.com/OZEUC.htm
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.