Avatar of SiddharthRout
SiddharthRout
Flag for India asked on

How would you define a User Defined Function?

Why is a function written for a worksheet called UDF but normal function written in VBA called a "FUNCTION" when both have been 'defined' by the user?

Any MSDN Article which actually defines what a UDF is?

Sid
Microsoft Excel

Avatar of undefined
Last Comment
SiddharthRout

8/22/2022 - Mon
SOLUTION
Ingeborg Hawighorst (Microsoft MVP / EE MVE)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
jppinto

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SiddharthRout

ASKER
Thanks Teylyn

@JP:
>>>The UDF is a function that the user creates for a specific purpose.

Isn't that true for normal functions as well :)

>>>The "normal" functions are functions that suite the needs of everybody that uses Excel.
Hmm, with respect, that is not true...

Sid
ASKER CERTIFIED SOLUTION
Rory Archibald

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SiddharthRout

ASKER
>>>UDF in the Excel context refers specifically functions created by the user that are called from the main Excel environment. Other functions are just functions, in much the same way that subroutines are subroutines, they are not UDS.

Thanks Rorya.

And hence my concern... where is it mentioned in MSDN that UDF in the Excel context refers specifically functions created by the user that are called from the main Excel environment.

>>>>There is, as far as I know, no specific reason for why this should be, other than probably the fact that they appear under the User Defined category in the Function Wizard.

This is a valid point however why the distinction? Why refer them as User Defined Function and create a confusion? If you wouldn't have updated me today, I would have still been under the impression that both are UDFs :) And hence my request for an Article which supports that UDF are functions written for worksheets...

Sid
Rory Archibald

I don't know if there is an article that defines UDFs, but that's what they are in Excel-land.

"Why refer them as User Defined Function and create a confusion?"

The whole point is to remove confusion, since:
1. It distinguishes native Excel functions from those added via code (of whatever sort - you can have UDFs in an XLL)
2. There are things that will work in a normal VBA function context that will not work in a UDF.

There is no law that says you have to comply with the usage. If you wish to refer to all code functions as UDFs, then feel free, but don't be surprised if people ask for clarification when you do. :)
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
SiddharthRout

ASKER
>>>>but that's what they are in Excel-land.

But they must have been based on some facts... Some Article? It cannot be that one day every just decided to call them as UDF and the other as Functions? :)

>>>but don't be surprised if people ask for clarification when you do. :)

I will point them to this thread :-D (Unless someone points me to a valid Article)

Sid
Rory Archibald

Probably the fact that they appear in the Function Wizard as user-defined functions.
SiddharthRout

ASKER
Since the normal function do not appear in the Function Wizard as user-defined functions doesn't make them 'Less' or 'Not User Defined' function...

I feel it is after all a difficult question. Upping the points...

Sid
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
zorvek (Kevin Jones)

Just what is a UDF anyway? When is a UDF not a UDF? When is a function a UDF? When I say it is? When someone uses it? So it shows up in the function wizard. What if I didn't ask the function wizard to do that? I have a lot of functions that show up in the function wizard that I never said are UDFs - are they UDFs? What is a function that is used by my VBA code as a function AND in a formula? Can I write a function and say "that's a UDF!" even though no one ever uses it in a formula? If not, then how does anyone know it CAN be used in a formula? Maybe I should call it a PUDF (Potential UDF). How about FTWTBAUDF (Function That Wants to be a UDF). How about WTFCWIIIW.
SiddharthRout

ASKER
Zorvek,

When you answer your first question, the rest of the questions will automatically fall in place ;)

So back to square one... >>>>Just what is a UDF anyway?

Sid
zorvek (Kevin Jones)

>Since the normal function do not appear in the Function Wizard as user-defined functions

What is a "normal function"? An NF? How do you make one? Every public function I define in a code module is made a UDF by the Function Wizard God - even if it can't be used as a UDF. Is an NF a private function?

This was deemed a UDF by the Function Wizard God!

Public Function MyNotAUDFFunction(ByVal SomethingWeird As Object) As Object
' Hey, Function Wizard thingy, this is NOT a UDF!

Oh my!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
zorvek (Kevin Jones)

I answered it at the end of that post ;-)
SiddharthRout

ASKER
>>>I answered it at the end of that post ;-)

>>>How about WTFCWIIIW.

I don't wanna guess WTF stands for... LOL

Sid
Rory Archibald

Methinks your question title should have been "How does Microsoft officially and in writing define a User Defined Function?" given the answer you seem to want. I answered the question as asked. :)
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SiddharthRout

ASKER
On a serious note...

What I could gather with all the conversation (minus Kevin's which didn't make sense to me LOL)

A UDF is a function which is written for a Worksheet. (There is no Article/Link) which can explicitly support this statement.

Well, I am not convinced... I will wait for more experts to join this discussion...

Sid
SiddharthRout

ASKER
>>>Methinks your question title should have been "How does Microsoft officially and in writing define a User Defined Function?"

Yes that is what I meant.

Thanks :)

Sid
Rory Archibald

In that case I bow out, as it's not important. ;)
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
SiddharthRout

ASKER
>>>given the answer you seem to want. I answered the question as asked. :)

And you shall get the points if I do not get the answer that I am actually looking for....

>>>In that case I bow out, as it's not important. ;)

I respect your decision. The knowledge that you shared is well appreciated and respected as usual :) This has become important to me so I will wait for more opinions... thanks once again Rory.

Sid
Rory Archibald

You should not give the points if you do not accept it as a valid answer.
SiddharthRout

ASKER
Why should I deprive you of points

1) If the explanation you gave is the general opinion of the Folks in Excel Land. Specially Post ID: 36151898

2) If Microsoft didn't put an article in place (unless someone comes up with one) ;)

Sid
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
aikimark

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SiddharthRout

ASKER
Thank you Aikimark

What you are saying is absolutely what Rory was earlier implying. However, question is how do you know/support what you just mentioned. Did you read it somewhere? Did someone tell you that?

Sid
zorvek (Kevin Jones)

So...what makes a UDF a UDF? Seems like it depends on the context.

As a developer writing VBA code I may create a function that I intend to be used from within a worksheet function. That is a UDF as far as I'm concerned.

As a user perusing the functions served up by the function wizard, a UDF is any non-built-in-function that is listed.

Are the two synonymous? Nope. The function wizard looks for any VBA functions that follow some basic characteristics: public, in a general code module, and do not accept parameters that are obviously not passable from a worksheet function (this is a weak area as I proved above). As a developer my UDF is public, in a general code module, accepts parameters that can be passed from a worksheet function, AND actually does something that makes sense in a worksheet function.

Maybe we need to add a statement to our real UDFs that actually define them as UDFs. Something like the Application.Volatile statement. Then we will have a definition. I intend for it to be a UDF and the function wizard agrees! Although we will need a new sub-definitition: FUDF or Fake UDF or a UDF that really isn't one but is masquerading as one because the developer mistakenly thought it might work as one and the function wizard kinda got caught up in the confusion.

So, what is a UDF?

WTFCWIIIW! (who the f*#k cares what it is it works)

Now, poink me! Poink Rory too for effort.
SiddharthRout

ASKER
>>>WTFCWIIIW! (who the f*#k cares what it is it works)

I do :)... Now...

>>> That is a UDF as far as I'm concerned.

Thanks for your opinion but that I am looking for is the 'Base' for your opinion...

Same question for you which I asked Aiki...

How do you know/support what you just mentioned. Did you read it somewhere? Did someone tell you that? :)

Sid
Your help has saved me hundreds of hours of internet surfing.
fblack61
Rory Archibald

Of course, as a developer, you would slap Option Private Module at the top of modules whose functions you did not want regarded as UDFs and then you and the FW would get along just fine. :)
I'm too tired to be poinked today - leave it a few days.
SiddharthRout

ASKER
I am actually wondering that if such an article or authoritative post exists which can be taken as a benchmark which confirms that functions which are called in worksheet are called UDF otherwise they are called functions...

Having said that...

>>>leave it a few days.

Lets do that... :)

Sid
aikimark

@Sid

It comes from decades as a software instructor and consultant.  It is knowledge gleaned from multiple views of software from different developers and presenters.  It is what I gleaned from reading the Microsoft product help files.  In essence, it comes from a great deal of experience.

As with most EE questions, the answer is strongly tied to context.  When we are working within some run-time environment (Office, SQL Server, Outlook, batch or browser scripting), there are intrinsic functions that are supplied by the environment.  Sometimes we add functions through libraries, such as WScript and WMI.  When I use such system libraries, I do not refer to them as user-defined.
Note: The use of framework or namespace libraries generally falls into a 'system' category.

When I use third-party, self-written, or open-source code, I usually refer to those routines differently.

Let's say that I needed to extend an intrinsic function.  I might even give it the same name as the original, so I would certainly refer to this extended version as user-defined.

If I'm working in a code environment, I rarely think of any function as 'user-defined'.  It would be silly and meaningless.

=====
@rory

That is mostly a packaging distinction, related to scope (visibility).
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Rory Archibald

I know - that was the point: to stop the Function Wizard from listing them. :)
aikimark

Clever.  

Since I usually have a mixture of public and private routines in any given module, so I avoid the Option Private statement and use Public and Private declaratives on my routines and variables.
SiddharthRout

ASKER
>>>It is what I gleaned from reading the Microsoft product help files.  In essence, it comes from a great deal of experience.

Which I understand and fully respect.

>>>If I'm working in a code environment, I rarely think of any function as 'user-defined'.  It would be silly and meaningless.

With Respect, I am sorry but why is it meaningless? If I go by this logic then I would find just naming functions called in Worksheet as UDF and not the others in spite of the fact that they both have been 'Defined' by the user meaningless... If I ignore the word USER and FUNCTION in UDF, I am left with DEFINED. What does DEFINED mean? But I guess that should be a new question :)

Please note that the objective of this question is to ascertain the fact (based on some article/authoritative post) on why are they called UDF and not functions or vice versa or both.

Thanks for your post. they have been very informative till now :)

Sid
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Rory Archibald

@aikimark,
The only issue is that, even with Option Private module, you can still call the function from the worksheet. (though that can be a good thing)
aikimark

@Sid

I still refer to them as subs, functions, or routines.  In this environment, everything is defined (although may be lately bound).  It is the user descriptor that I usually drop.

Things get murky when you consider that we can use call-by-name to invoke a function that may not be viewed by the compiler as a function.
StephenJR

If I ignore the word USER and FUNCTION in UDF, I am left with DEFINED. What does DEFINED mean?
If we're being properly precise, user-defined should be hyphenated so then the "defined" is only meaningful in relation to "user". You cannot split it into words. In essence, the user as opposed to Microsoft I suppose.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SiddharthRout

ASKER
@Aiki: thank you
@Stephen: Let me approach it from a different angle and then we will come back to the main point. Let's forget Excel for a moment... How would you define "User-Defined" or "User Defined"

Sid
StephenJR

Sid: I am clearly missing something because to my simple mind it seems pretty straightforward. When I open Excel it comes with some functions which I can use. They are not used-defined. Functions created by users are, by definition, user-defined!

You said without reference to Excel, but the definition is the same whatever it is applied to. If I paint a picture it is a user-defined picture. I may have based it on the work of somebody else, I used the paint and equipment made by others, but I took all that and made something that didn't previously exist. In Excel that may not be strictly true as undoubtedly many people will have independently written the same function, but you get the gist.
aikimark

@Sid

user-defined is a modifier (usually adjective) of something.

user defined is a sentence predicate.
Example:
"Mongo DB Is Web Scale"
In this sentence
* "Mongo DB" is the subject.
* "Is" is the verb
* "Web Scale" is the predicate.

BTW... http://www.youtube.com/watch?v=b2F-DItXtZs
is hilarious.  It is not safe for work.
video and transcript: http://www.mongodb-is-web-scale.com/
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
SiddharthRout

ASKER
>>>Functions created by users are, by definition, user-defined!
>>>You said without reference to Excel, but the definition is the same whatever it is applied to. If I paint a picture it is a user-defined picture.

Bingo! Exactly my point and hence this entire discussion :)

So if you define a function in Excel which is not used in Worksheet why are they not called User Defined? Did the user not define that function (or paint that picture if I may say so)? So why the distinction?

Sid
StephenJR

Sid - I have to confess I did not read your original question properly and had not picked up the distinction being made between worksheet and VBA. Now that I have, like you, I have no idea why such a distinction exists! We must abolish it forthwith.

Although are you sure that user-defined functions in VBA are not labelled as such - I don't think there is anything hard and fast about this.
SiddharthRout

ASKER
>>>>Although are you sure that user-defined functions in VBA are not labelled as such - I don't think there is anything hard and fast about this.

That what I am trying to find out.

All the posts above by various experts indicate that Functions which are used in a worksheet are called 'User-Defined Functions' else they are called just 'Functions'

My question is 'Why'? The 'why' has to be supported by a valid article or authoritative post preferably by MSDN (I am still searching... There might not be one else I am sure Rory would have found it till now...)

Most of the answers that I have got is that it is a very well known fact or it is widely acceptable. But somehow I am not convinced.

On a lighter note do you remember it was a well know 'fact' that all planets revolve around 'Earth' :D

Sid
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
aikimark

@Sid

I think it is time for you to differentiate your "user" references for us.  We are developers.  We would normally use the "user-defined" modifier when we are in the (higher) application context -- not when we're in our code context.
SiddharthRout

ASKER
@aikimark: Thanks Aiki. Somehow I had missed your post. My apologies. I have a very slow internet connection today but I will definitely watch that video later :)

Sid
StephenJR

"do you remember it was a well know 'fact' that all planets revolve around 'Earth'"

What do you mean "was"?

I think you have perhaps set up a straw man. If that is how most people understand the terms it makes sense to perpetuate them and there is unlikely to be much scope for ambiguity. I think you can call them whatever you like as long as you explain your terms.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
SiddharthRout

ASKER
>>>I think it is time for you to differentiate your "user" references for us.  We are developers.  We would normally use the "user-defined" modifier when we are in the (higher) application context -- not when we're in our code context.

Agreed Aiki but that still doesn't explain things as a developer is also a 'user'. Or am I missing a point here?

Sid
SiddharthRout

ASKER
>>>What do you mean "was"?

Not sure how to answer that question :)

>>>If that is how most people understand the terms it makes sense to perpetuate them and there is unlikely to be much scope for ambiguity.

With respect, I disagree. :)

Sid
StephenJR

Just being facetious Sid.

Can you give an example of a situation in which the interchangeable use of Function/UDF could cause confusion?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SiddharthRout

ASKER
>>>Can you give an example of a situation in which the interchangeable use of Function/UDF could cause confusion?

Well it's not the 'use' but addressing it as a 'UDF' or a 'normal function' is causing the confusion.

Actually this question came to my mind when I was discussing it with another expert and I came to know that I was not supposed to address it as a UDF but as a 'Function' :)

Like Rory mentioned let's give it a day or so... Maybe some one might come across a link to an article or post which I am looking for :)

Sid

aikimark

CONTEXT is king.

If you are 'in' a worksheet (typing a formula) or a query/form/report designer, any non-intrinsic and non-system function should be considered user-defined.  If you typing VBA code 'in' the VB project window, they are just functions/subs/routines/methods.  
zorvek (Kevin Jones)

>The only issue is that, even with Option Private module, you can still call the function from the worksheet. (though that can be a good thing)

Oh my! Then we have a not-a-UDF function (according to Rory) not only acting like a UDF function but being used as a UDF. It's a GUDF (Ghost UDF)!

>Of course, as a developer, you would slap Option Private Module at the top of modules whose functions you did not want regarded as UDFs and then you and the FW would get along just fine.

As a developer I don't use Option Private Module to do that. I can't. I build SDKs for other developers and Option Private Module hides my super cool functions from them. And these super cool functions are NOT UDFs or GUDFs or any other kind of UDF.

>So if you define a function in Excel which is not used in Worksheet why are they not called User Defined? Did the user not define that function (or paint that picture if I may say so)? So why the distinction?

Because. Why do I tell you to eat my shorts? Because. Why does the pope wear a beanie? Because. Why does a bear shit in the woods? Because.

Here's the deal, dude. Every damn definition ever uttered from Homo Sapiens is just that: another damn definition uttered from some stupid Homo Sapien. It's all just a bunch of made up crap. Confused idiots like you and me wrote all this shit running on our computers. They designed Excel - I actually do know one of the original brains behind Excel - and he IS nuts. I have also also talked to Mitch Kapor about his rendition of the spreadsheet before Microsoft decided to copy THAT little goodie and he's a bloke just like you and me. Made the whole thing up out of his head.

If you go to a pub with Rory and spend a penny are you buying some really cheap beer? Where's the pub?

This is a rathole. The more you go down it the more questions you will have. You had your answer before you read about UDFs. And then you read about UDFs and started your path to this question, becoming more and more confused along the way. And here you are, more confused than ever. Look up rathole. Now there is a solid definition!

What is a UDF? Depends.

Depends on what? Who you ask. What you are doing. Who you are. What day of the week it is. What someone posted last week that is probably just more made up hyperbolic "see me, I'm smart" crap. My context. Your context. Their context.

Who cares? No one but you.

Ignorance is bliss.

My context: I'm happy with the notion that UDF is just another somewhat whacked term based on a loose set of criteria. Now poink me or eat my shorts.

Here's a question for you: Suppose the Definition God/King/Superhero came to you and said "Sid, a UDF is ... no more, no less, and you can take that to the proverbial bank. Oh, and stop using so many ellipses." How would that change your life? Would you be any happier? What would you do with your new knowledge?

Can the answer really be "it depends"?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
StephenJR

I think at least part of what zorvek said was summed up by Shakespeare thus:

"What's in a name? that which we call a rose
By any other name would smell as sweet;"
SiddharthRout

ASKER
@Kevin: Whoa :) Will you be still there when I decide to make a movie :)

>>>My context: I'm happy with the notion that UDF is just another somewhat whacked term based on a loose set of criteria.

I am almost on the verge of believing that. :)

>>>(Here's a question for you: Suppose the Definition God/King/Superhero came to you and said "Sid, a UDF is ... no more, no less, and you can take that to the proverbial bank.)

>>>How would that change your life?
Wow. I should think this every time I answer a question in a forum or before taking another step? Or probably before opening my fridge to pick up a bottle of beer. Or probably before smelling a rose. Or probably this. Or probably that. How would that change my life? I don't do things always to change my life. I am pretty much happy with the kind of life I have. Do you really think it is meaningless to find answers to questions if it doesn't 'Change' your life? With respect, Kevin but now you are not making any sense to me at least. And I am okay if you tell me "Eat My Shorts" :)

>>>Would you be any happier?
Depends on how you define 'happy'?

>>>What would you do with your new knowledge?
Er, Mark this thread resolved and give him the points? :-D

Sid
SiddharthRout

ASKER
Now I am actually wondering if I am asking for too much?

All I am asking is if there is any link/Article/post which can tell me exactly what I want to know?

If I am asking for the impossible then please let me know and I will close this thread... :)

Sid
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
aikimark

@Sid

We must use language to communicate.  As long as you define the terms you use or agree to a definition with whom you are communicating, you shouldn't have to worry.  Just be sure to use the terms consistently.

Remember that "rubber" means very different things in the UK than it does in America.  Even in different parts (and sub-cultures) of America words have very different meanings and connotations -- take Santorum, for instance.
SiddharthRout

ASKER
Thank you Aiki.

I understand and accept what you say. But my concern is... let me explain it with an example.

>>>As long as you define the terms you use or agree to a definition with whom you are communicating, you shouldn't have to worry.  Just be sure to use the terms consistently.

Let's say you, me, Rory, Stephen, Teylyn, Kevin agree to a definition that a function which you write in VBA (immaterial of the fact whether it is used in a worksheet or not) should be called WTFCWIIIW. Do you think it will be acceptable on a GLOBAL level? Would it be right to assume that it will be acceptable? Considering the fact that tomorrow I might have to answer someone's question here in EE or any other forum? What would I use there?

I would still like to call both functions UDF as per my understanding. But what if I am wrong as per some MSDN article? I am not trying to dispute anything that you or any other expert said in reference to a UDF. All I am asking is what is it based on? Or is it like what Kevin said "I'm happy with the notion that UDF is just another somewhat whacked term based on a loose set of criteria."

Thanks once again.

Sid
SOLUTION
dlmille

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
aikimark

In the SQL Server environment, there is actually a UDF that is called a User-Defined Function.  In addition, we can now add a different flavor of UDFs by way of .Net assemblies.  The nomenclature can get downright confusing.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
zorvek (Kevin Jones)

The first sentence in that MSDN article: "User-defined functions (UDFs) are custom functions that extend the calculation and data-import capabilities of Excel."

There you go. Another person making a statement about what a UDF is. So, who is this person? What makes them qualified to make a statement such as this? Are they somehow a level above the rest of us and we can safely assume their lofty wisdom makes them qualified to make such a statement and that any statement they make is absolute truth?

Or are they just another yahoo like you or me who is trying to make a living, make name for themselves. Maybe they were asked by someone else to write an article on UDFs. Maybe they said to themselves "Shit! What is a UDF? Dang, it's kind of a loosely defined term! Hmmm...I need to do this so I can finish this stupid assignment - I'll give it a go and hopefully it will be accepted by my peers. I know, I'll keep it somewhat vague so that Rory won't find some hole in it."

And so goes the definition merry-go-round. Someone comes up with the cool idea to allow VBA functions to be called from worksheet formulas, the documentation writer asks "Hey, that's interesting, what do we call it?", the developer says "Huh? Do we have to call it something?", the documentation writer says "Of course! I have to have a header and a TOC entry and, besides, the marketing people will want to sell it and they love cool names!" and then asks a few more questions and hears "VBA" and "function" and "formula" and "neat" and "cool" and puts something together - maybe "Custom VBA Worksheet Functions" or "CVBAWF" - and then the marketing people get a hold of it and, not knowing their ass from a cell but knowing what resonates with the masses, coin some silly phrase like "User Defined Function" or "UDF" so they can market it and make lots of money to pay the developers and stock holders, they release the product and the MVPs ask "What the hell is a UDF?" and then one of them says "It's a VBA function that is ..." and the other MVPs oooo and ahhhh and quote the first MVP and add their own little nuances, and, and...

Meanwhile the developer who dreamed up the idea is now trying to figure out why the statistics functions suck and can't remember the conversation he had with the documentation department. Someone says to him "Hey, dude, you invented them UDFs all the MVPs are going on about! Nice job!" to which he replies "What's a UDF?" After he is told he replies: "I never created something special or different. All I did was allow public functions in general code modules to be used in worksheet functions. Pretty cool, eh? UDF? Why do we have to call them UDFs? They're just public VB functions versus procedures and I made them available to the worksheet!"

So what did that MSDN article say a UDF was? Something about extending calculation and, yes, data-import capabilities of Excel. And we have yet another whacked definition written by someone who has a title and for a distribution medium that we believe, because it has "MSDN" in the name, is a credible source, and we, for a moment, believe we have an answer. To what? A question that never really had an answer in the first place. Oh, but it sure is fun to think there IS an answer! And SOMEONE out there knows it! Just need to find 'em...

---

Here is one for you: Excel 4 Macro-Sheet Functions. Can we call them UDFs? Wait a second - the Excel 4 help refers to them as "Custom Worksheet Functions"! Now what do we do?

---

Rathole: [from the English idiom “down a rathole” for a waste of money or time] A technical subject that is known to be able to absorb infinite amounts of discussion time without more than an infinitesimal probability of arrival at a conclusion or consensus.

Thank you Rory: "@Sid, In Excel-ese UDFs are functions called from worksheets; otherwise they are just functions."
Rory Archibald

"A good debate is always healthy as long as no one gets a bloody nose." - some douche. ;)
zorvek (Kevin Jones)

This is a debate?

And that's Mr. Dick Douche bud.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SiddharthRout

ASKER
@David: Thanks for the link :) Much appreciated.
@aikimark: Thank you as usual.
@Rory: I agree

@Kevin: I am sure you must have the same thoughts about the Bible as well.

"So, who is this person? What makes them qualified to make a statement such as this? Are they somehow a level above the rest of us and we can safely assume their lofty wisdom makes them qualified to make such a statement and that any statement they make is absolute truth?"


Aw come on Kevin... :)

Ms Office is Microsoft's baby. And if they hire 'THIS' some one who says it is what it is and Microsoft doesn't have any problem then whats wrong with it? If that guy calls it a WTFCWIIIW and Microsoft approves it then I will go with that definition. Tomorrow if you own Microsoft and you hire someone who calls it something else then I will go ahead with that... For me It is as simple as that...

>>>>Rathole: [from the English idiom “down a rathole” for a waste of money or time] A technical subject that is known to be able to absorb infinite amounts of discussion time without more than an infinitesimal probability of arrival at a conclusion or consensus.

Yet you are wasting your time on me with such huge posts? ;-)

Sid
Rory Archibald

It's a discussion involving contrasting points of view, so yeah. Sorry, Dick. :)

How was France, BTW?
zorvek (Kevin Jones)

>I am sure you must have the same thoughts about the Bible as well.

Hell no! The Bible is a super cool story written by some old men who wanted to ... oh, never mind.

>For me It is as simple as that...

I'm a Microsoft Excel MVP. What I say is gospel 'cause I'm so like super smart (although not as smart as Rory or Brad) and my daughter says so and I have more points than you. A UDF is a function that is, at the moment of execution, called from a worksheet formula. Otherwise it is a regular old function. Confused? Here is the code:

Public Function PolymorphousFunction()
   If TypeName(Application.Caller) = "Range" Then
      MsgBox "I'm a UDF!"
   Else
      MsgBox "I'm NOT a UDF!"
   End If
End If

Note: You can also deem your otherwise normal old function a UDF and, by the laws of zorvek, it shall be so, even if it crashes Excel.

There is your answer. Poink me.

>Yet you are wasting your time on me with such huge posts.

I never said I didn't like ratholes. Maybe I actually enjoy watching people find their own rat holes and then deftly pushing them further and further down to see just how far they will go ;-) And it's a slow day.

>It's a discussion involving contrasting points of view, so yeah. Sorry, Dick.

Contrasting points of view? Where's the contrast? This looks more like a snipe hunt - one that you started by recruiting our innocent little camper buddy Sid - and the rest of us are offering all manner of hooha to the poor chap as he spins more and more with the noise while becoming increasingly convinced that there simply must be an answer out there somewhere. It's classic good fun.

>How was France

I'm still here. Fun with Harley and beautiful French girl. Went to the coast yesterday. Who knows where tomorrow.

https://www.experts-exchange.com/admin/member/editMember.jsp?mid=4512506

I got in a heap of trouble that day.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Rory Archibald

Nice. (as in nice, rather than Nice)
I'd have gone with Dr. rather than Mr. just for the alliteration.
SiddharthRout

ASKER
The last End If should be End Function. But then I guess you are testing me ;)

Are you saying that If you call this from a worksheet then it is a UDF. and if you call it from a sub then it is not?

Sid
SiddharthRout

ASKER
It's unfair. I cannot access that link... :)

Sid
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
zorvek (Kevin Jones)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SiddharthRout

ASKER
Thank you Kevin

"After all we are just two lost souls swimming in a fish bowl" - PF

Conclusion:
As I suspected there is no Official definition for a UDF. The most common definition accepted 'unofficially' in the "Excel Land" is that the worksheet functions are functions which are called from the worksheet. In such a scenario it is to one's whims and fancy whether one wants to call all the functions defined by a ‘User’ a User-Defined Function or just the functions that are called from the worksheets, a UDF.

Note: If anyone disagrees, then I am still open for a link/Article which proves it otherwise.

Thanks to

Teylyn/Jppinto: For expressing their opinion and not digressing from the topic.
Rory: As usual for sharing his knowledge. As I have mentioned earlier. I envy you. :)
Aiki: Sharing your knowledge and sticking with me till the end.
David: Sharing that interesting link.
Stephen: Sharing your opinion.
And last but not the least
Kevin: For keeping us (me at least) entertained and sharing 'some' very good points.

Sid
SiddharthRout

ASKER
The reason for selecting my own answer is mentioned in my previous post.

Thanks again every one.

Sid
SiddharthRout

ASKER
Strange.

I had selected my own answer as the accepted solution and it also asked me for a reason but somehow it didn't select my question as 'accepted'...

Anyways...
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck