View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
joeu2004[_2_] joeu2004[_2_] is offline
external usenet poster
 
Posts: 829
Default From where is my UDF called?

PS.... I wrote:
"joeu2004" wrote:
Dim s as String
On Error Resume Next
s = Application.Caller.Address
On Error GoTo 0
If Len(s) = 0 Then MyFunction = False: Exit Function


I began to wonder why you want this.

If your real intention is simply to prevent MyFunction from being called
from Excel worksheets, perhaps it would be sufficient to make MyFunction
private, to wit:

Private Function MyFunction(...) As Variant

Potential downside: MyFunction can be called only from procedures in the
same module.

I think you could work around that limitation by putting MyFunction into a
class module.