View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
tony h[_146_] tony h[_146_] is offline
external usenet poster
 
Posts: 1
Default .Precedents don't work in UDF


I ran the code a s a sub which was ok then changed it to a formula which
wasn't.

Sub a()
Dim rng As Range
Dim str As String
Dim mycell As Range

Set mycell = Selection

str = "direct : "
For Each rng In mycell.DirectPrecedents
str = str & rng.Address & " , "
Next


str = str & " indirect : "
For Each rng In mycell.Precedents
str = str & rng.Address & " , "
Next
Debug.Print str

End Sub
should work all right as a sub. Need to think about why it failed as a
formula. Maybe it needs the cell selected?

Sorry need to go


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=557454