Call VBA Class Module in Excel formula -
i know function of module can called in formula this:
=getmymodulefunction()
now call class module function. don't know if class module can instantiated in formula @ i've created function in module can call =getmymodulefunction()
:
' class module myclassmodule: public property myproperty() string myproperty = "hello world!" end property public function getmyfunction() string getmyfunction = "hello world!" end function ' end class module myclassmodule ' module mymodule: public function getmyclassmodule() myclassmodule set getmyclassmodule = new myclassmodule end function ' end module mymodule
so after tried in formula bar:
=getmyclassmodule().getmyfunction() =getmyclassmodule().myproperty
which shows error dialog formula invalid. not possible i'm trying achieve here? use modules instead functions , subs duplicate names confusing , error prone use in modules..
your question similar question asked here: call vba function returns custom type spreadsheet
you can return data types excel understands user-defined function. excel not understand custom data types.
but can wrap class properties or functions regular module function (udf) so:
public function getmyclassmodulefunction() string getmyclassmodulefunction = getmyclassmodule.getmyfunction() end function
Comments
Post a Comment