Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Finding external cell dependents works in a Sub() but not a UDF.

In Excel 2002 SP 3, I need a UDF that displays a concatenated string
of the texts of the external dependents of a given cell.

So if say Sheet1!A1 has 3 external dependents--Sheet2!A1 (text “cat”),
Sheet2!A2 (“dog”) and Sheet3!A1 (“bird”), then formula “=MyUDF(Sheet1!
A1)” should return “catdogbird”.

But I find no posts using .NavigateArrows in a Function(). All
examples are Sub()’s. True to that, this code:

Do
Set D = .NavigateArrow(False, 1, i)
If Not (D.Worksheet Is SourceRange.Worksheet) Then
Result = Result & D.Text
End If
i = i + 1
Loop Until <Whatever

works perfectly for me (cycles thru all externals) in a Sub(), but
fails in a Function().

Can it therefore not be done in a UDF?

If not, do any of you Knights of the Web have a workaround?

Thanks very much.

***

[P.S. The first post on:

http://groups.google.com/group/micro...ba3a450db971a2

intriguingly is in a Function(). But it self-defeats because its first
line:

If TypeOf Application.Caller Is Range Then GoTo theExit

is always true (at least for me), hence his code never executes. And
anyway, he uses the same .NavigateArrows logic as above, and if you
comment out the above line it fails as expected.]

***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Finding external cell dependents works in a Sub() but not a UDF.

I didn't use the NavigateArrows method (I just don't know what it
does) but this works for me:

Public Function ConcatenateDependantCellsTexts(TheMasterCell As Range)
As String
Dim v As Range

For Each v In TheMasterCell.Dependents
ConcatenateDependantCellsTexts =
ConcatenateDependantCellsTexts & v.Text
Next v

End Function


But!! - keep in mind that you can't really use it in a cell as a
function because it would cause a circular reference - i.e., just by
entering this function you'd increase the MasterCell's dependatns by 1
(i.e, the cell that you enter the function into will also become a
dependent of the mastercell.

Also, as far as i know the only real difference between sub and
function is that a function returns a value whereas sub doesn't.



On Jun 24, 12:26*am, wrote:
In Excel 2002 SP 3, I need a UDF that displays a concatenated string
of the texts of the external dependents of a given cell.

So if say Sheet1!A1 has 3 external dependents--Sheet2!A1 (text “cat”),
Sheet2!A2 (“dog”) and Sheet3!A1 (“bird”), then formula “=MyUDF(Sheet1!
A1)” should return “catdogbird”.

But I find no posts using .NavigateArrows in a Function(). All
examples are Sub()’s. True to that, this code:

* * Do
* * * Set D = .NavigateArrow(False, 1, i)
* * * If Not (D.Worksheet Is SourceRange.Worksheet) Then
* * * * Result = Result & D.Text
* * * End If
* * * i = i + 1
* * Loop Until <Whatever

works perfectly for me (cycles thru all externals) in a Sub(), but
fails in a Function().

Can it therefore not be done in a UDF?

If not, do any of you Knights of the Web have a workaround?

Thanks very much.

***

[P.S. The first post on:

http://groups.google.com/group/micro...rogramming/bro...

intriguingly is in a Function(). But it self-defeats because its first
line:

If TypeOf Application.Caller Is Range Then GoTo theExit

is always true (at least for me), hence his code never executes. And
anyway, he uses the same .NavigateArrows logic as above, and if you
comment out the above line it fails as expected.]

***


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Finding external cell dependents works in a Sub() but not a UDF.

AB:

Thanks much for reply.

***
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
How to traverse cell.Dependents joeu2004 Excel Programming 4 February 15th 08 12:10 PM
external data works in 2003 not in 2000 mikeolson Excel Programming 2 March 13th 07 01:14 PM
External link only works for numbers -- for text values, #N/A is displayed unless linked file is open Sven Filter Links and Linking in Excel 1 February 22nd 05 08:10 AM
Checking cell for Dependents ExcelMonkey[_188_] Excel Programming 1 November 15th 04 01:11 PM
Checking cell for Dependents ExcelMonkey[_187_] Excel Programming 1 November 14th 04 11:33 AM


All times are GMT +1. The time now is 12:19 AM.

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

About Us

"It's about Microsoft Excel"