S
Stephen Bianchi
Does anyone know how to return a reference to an object
(from a VBA function) to a cell on an Excel worksheet, and
then use that reference (that is sitting in the worksheet
cell) as an argument to another VBA function?
Something like:
Public Function fun1() as myClass
Dim myObject as new myClass
...bunch of code that does stuff
fun1 = myObject
End Function
Public Function fun2(myObj as myClass) as double
fun2 = myObj.getDblValue
End Function
Let's say I want to call fun1 from cell A1 on Sheet1 in my
Excel workbook. Then I want to call fun2 with the
reference to the object created by fun1 (let's say from
cell A2):
in cell A1:
=fun1()
in celll A2:
=fun2(A1)
Why? Well, maybe my fun1 does a tremendous amount of
work. So, I would like to execute it only once, but then
be able to query the object (created by fun1) several
times with functions like fun2, without having to rerun
fun1 every time.
I am pretty sure it is possible to do this, because I have
seen the functionality. But I don't know the technical
details of how to actually do it.
Any help would be greatly appreciated!!
(from a VBA function) to a cell on an Excel worksheet, and
then use that reference (that is sitting in the worksheet
cell) as an argument to another VBA function?
Something like:
Public Function fun1() as myClass
Dim myObject as new myClass
...bunch of code that does stuff
fun1 = myObject
End Function
Public Function fun2(myObj as myClass) as double
fun2 = myObj.getDblValue
End Function
Let's say I want to call fun1 from cell A1 on Sheet1 in my
Excel workbook. Then I want to call fun2 with the
reference to the object created by fun1 (let's say from
cell A2):
in cell A1:
=fun1()
in celll A2:
=fun2(A1)
Why? Well, maybe my fun1 does a tremendous amount of
work. So, I would like to execute it only once, but then
be able to query the object (created by fun1) several
times with functions like fun2, without having to rerun
fun1 every time.
I am pretty sure it is possible to do this, because I have
seen the functionality. But I don't know the technical
details of how to actually do it.
Any help would be greatly appreciated!!