Create UDF in Class Moduels? (frm Leo)

L

Leo

Dear Experts,
I recently became interested in style of using Class Modules.
I need to know if we can use Class Modules to creat User Defined
Functions?
(functions that is useable in Excel sheet like a normal worksheet
function)
if yes, please explain how, and show a simple sample.
thanks in advance.
 
C

Chip Pearson

A class module is particularly unsuitable for UDFs, because you must
create an instance of a class to use anything contained within the
class, and Excel has no knowledge of what objects may or may not have
been created by VBA at any particular time. As a general rule, UDFs
should be in regular code modules, not class modules. For more info
about class modules, see http://www.cpearson.com/Excel/Classes.aspx.
For more info about UDFs, see
http://www.cpearson.com/Excel/WritingFunctionsInVBA.aspx.

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top