View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Direct Precedents of a cell

It won't work from a worksheet as I explained, and I am afraid I don't
have a solution.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"jdcox1999" wrote in message
oups.com...
I get it to work from another sub but not from a worksheet cell (see
below). Any suggestions?


Sub testfunction()
Dim i As Boolean
i = IsDirectPrecedentOf(Range("BN45"), Range("BP45"))
MsgBox (i)
End Sub


Public Function IsDirectPrecedentOf(ByRef SubjectCell As Range, ByRef
ObjectCell As Range) As Boolean
IsDirectPrecedentOf = False
If Not Intersect(SubjectCell, ObjectCell.DirectPrecedents) Is Nothing
Then
IsDirectPrecedentOf = True
Else
IsDirectPrecedentOf = False
End If
End Function


Bob Phillips wrote:
Sounds good, but there is a problem. It doesn't work.

DirectPrecedents seems to work differently in a User Defined Function.
Presumably, this is a function of the calculation
engine.

--
HTH

Bob Phillips