Hi,
Does anybody know how I can go about calling a Function of a VBA Class (Not from a module) as a User Defined Function in an excel sheet?
Thanks.
Ed
Hi,
Does anybody know how I can go about calling a Function of a VBA Class (Not from a module) as a User Defined Function in an excel sheet?
Thanks.
Ed
You can not use the function directly you would need to create an object and re reference that. It would also require a wrapper function in a module to do it.
Class1 code
module codePlease Login or Register to view this content.
reference from sheet cellPlease Login or Register to view this content.
=ClassWrapper_Username()
It would be better to copy the function to a module.
Cheers. Can I add... Is there a way to have Functions at Module level but prevent them from being called as a UDF (without having to place the functions into code behind sheet). I guess it is possible to make them invisible to the functions listing but user could still type in manually the function name...?
Option Private Module, will exclude the function name from intellisense if typed in cell.Please Login or Register to view this content.
Checking application.caller can be used to restricted action of function
Cheers, Andy!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks