Thread: UDF Question
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
AA2e72E AA2e72E is offline
external usenet poster
 
Posts: 400
Default UDF Question

Try this function:

Function abc(ByVal Cell1 As Range, cell2 As Range)
abc = Cell1.Value + cell2.Value
MsgBox Cell1.Address & " " & cell2.Address
End Function

Since there is no way of determining which cell changed to cause the
function to be called, the MsgBox returns the address of both cells.

"Koye Li" wrote:

Thanks for the help. But Application.Caller wouldn't help in this case.
Since Application.Caller only gives the cell which the UDF call is
originated. But what I am interested is which cell in the UDF argument list
that triggers the UDF call.

"AA2e72E" wrote in message
...
Lookup the topic/example Application.Caller in the help files

"Koye Li" wrote:

Let say we have defined an UDF fuction foo(a,b) that takes 2 cell
references
as its arguments :

public function foo(byval a, byval b)

and on the worksheet, we have

=foo(B1,C1)

Whenever B1 or C1 changes, foo() gets triggered and is called by Excel.
Is
there anyway within foo() to tell which argument originated the call?