View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Niek Otten Niek Otten is offline
external usenet poster
 
Posts: 3,440
Default Another UDF Question

Hi Eric,

If you don't mind, your post is a bit "vague" in some places;

<do some other stuff What stuff
<changes to cells that affect my UDF affect HOW?
<object the UDF is controlling ?????

If you include all cells that influence the result of your UDF in the
argument list (and then, of course, in the list of arguments of the function
call in the worksheet), then everything should work OK.
No need to trap events.
Note that functions can return a value to replace their call, nothing else.
They can not change cells, formats, really nothing at all. That is, as long
as they are called from worksheets, directly or indirectly.

If that doesn't answer your question, please post back and explain what you
are trying to achieve.


--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"EricG" wrote in message
...
I have a UDF that refers to a range of data, for example, =My_UDF(A2:G45).
I
would like to be able to relate a change in any cell in that range to the
UDF
that is using that range, so that I can update the object the UDF is
controlling. I am trying to avoid using Application.Volatile because that
is
overkill, but I want to "trap" changes to cells that affect my UDF.

For example, if I change the value of cell B24, then I would like to be
able
to go into the Worksheet_Change event, relate the change in B24 to the UDF
that is referencing that cell (through the range A2:G45), and then do some
other stuff related to that UDF.

Question: Is there a way in VBA to determine what functions are
referencing
any particular cell on a worksheet? I would like to be able to generate a
list of all the functions that use a particular cell. If my UDF uses a
cell
that changes, I want to do some selective updating of the object
controlled
by the UDF.

Thanks,

Eric