Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default .Precedents don't work in UDF


I need to use the precedents of the cell that is the argument of
user-defined function as well as the cell itself. But if I write
Function MyFormula (MyCell as Range)
MyCell.Precedents don't work in this function. What can be done wit
it

--
Andruh
-----------------------------------------------------------------------
Andruha's Profile: http://www.excelforum.com/member.php...fo&userid=3595
View this thread: http://www.excelforum.com/showthread.php?threadid=55745

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default .Precedents don't work in UDF


I'm not even really sure what precedents are, but you could try

Function MyFormula (MyCell as object)

instead..

--
lcorey
-----------------------------------------------------------------------
lcoreyl's Profile: http://www.excelforum.com/member.php...nfo&userid=204
View this thread: http://www.excelforum.com/showthread.php?threadid=55745

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default .Precedents don't work in UDF


An example


Function MyFormula(ByRef MyCell As Range)
Dim rng As Range
Dim str As String

For Each rng In MyCell.Precedents
str = str & rng.Address & " , "
Next
MyFormula = str
End Functio

--
tony
-----------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...fo&userid=2107
View this thread: http://www.excelforum.com/showthread.php?threadid=55745

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default .Precedents don't work in UDF


tony h Wrote:
An example


Function MyFormula(ByRef MyCell As Range)
Dim rng As Range
Dim str As String

For Each rng In MyCell.Precedents
str = str & rng.Address & " , "
Next
MyFormula = str
End Function


Perhaps something is wrong with my Excel, but the fact is that this
code doesn't work :( It returns only the address of MyCell (God knows
why! )


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

  #5   Report Post  
Posted to microsoft.public.excel.programming
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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default .Precedents don't work in UDF


I also tried to create Sub()-procedure when I detected the problem :(
The same result.
I explored the I-net - think here is the explanation of the problem:
http://support.microsoft.com/?scid=k...=1759&sid=1289
But how can I solve it in this particular situation? Perhaps somebody
can give a piece of advice?


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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default .Precedents don't work in UDF


I don't thik that is the answer. The range is being passed by referenc
and nothing is being changed on the worksheet. A value is being passe
back but that is valid.

regards,
interesting. Might have a chance to play about with this on Tuesday i
it has not been resolved

--
tony
-----------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...fo&userid=2107
View this thread: http://www.excelforum.com/showthread.php?threadid=55745

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default .Precedents don't work in UDF

Hi Andruha,

The only thing what I can think of is to capture the change of any of
the changed cells with the Worksheet_Change event subroutine. Use
Tony's code on the "Target" parameter to find the precedents and just
insert them in the sheet where you want them.
Not very elegant, but it should work.

If you can't figure out how, let me know and I'll spend some time
coding it.

Regards,

Lex

But how can I solve it in this particular situation? Perhaps somebody
can give a piece of advice?


Reply
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
tracing precedents Ricardo Monroy Excel Worksheet Functions 1 July 28th 08 06:27 PM
Precedents Abdul Shakeel Excel Discussion (Misc queries) 3 July 25th 08 08:08 PM
Cell Precedents Kaval Excel Programming 2 April 5th 05 08:16 AM
Precedents do not work Paula Excel Worksheet Functions 1 March 30th 05 08:40 PM
Precedents Property Derek[_6_] Excel Programming 1 November 8th 03 12:51 PM


All times are GMT +1. The time now is 12:31 PM.

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"