Note that there are some explanatory texts on larger screens.

plurals
  1. POReturn a User Defined Data Type in an Excel Cell
    primarykey
    data
    text
    <p>I've searched the web and I've searched the questions here on stackoverflow, but I haven't been able to find a solution.</p> <p>Here is what I'd like to do:</p> <p>Suppose I have the following code in a class module named "MyClass"</p> <p><pre><code> Option Explicit Dim var1 as integer</p> <p>Sub Initialize(v as integer) var1 = v End Sub</p> <p>Function GetVar1() GetVar1 = var1 End Function </pre></code></p> <p>Then I have a UDF in a separate module with the code <pre> <code> Function InitializeMyClass(v as integer) as MyClass Dim myvar as MyClass Set myvar = new MyClass Call myvar.Initialize(v) Set InitializeMyClass = myvar End Function</p> <p>Function GetMyVar(m as MyClass) GetMyVar = m.GetVar1() End Function </pre></code></p> <p>Now in cell A1 I have "=InitializeMyClass(3)" and in Cell A2 I have "=GetMyVar(A1)". I get #VALUE errors in both cells. This of course is caused by the fact that I am trying to return a user defined data type into cell A1. I feel that this should be possible, but I am not sure how. </p> <p>Edit: Oh yeah, the question is, "Is there a way for me to return a user-defined data type into a cell and then have it be callable from another UDF in the example I gave above? I don't know if this requires COM or not. If it does, anyone know how I can get started? Ideally, if someone had an example of how this worked, that would be fantastic!"</p> <p>Another Edit: Here we go, now i know it can be done: read this description, it's not quantitative, but will give you a sense of what they do, <a href="http://www.quanttools.com/index.php?option=com_content&amp;task=view&amp;id=19" rel="nofollow noreferrer">http://www.quanttools.com/index.php?option=com_content&amp;task=view&amp;id=19</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload