Generic List of Structs in VBA
<p>I started working in Excel with VBA and would like to save some kind of List.</p>

<p>My approach is the following, but I fear that I am looking into the totally wrong direction.</p>

<pre><code>Public Type MyType
  ID As Integer
  Name As String
  MyInt As Integer
End Type

Public ListVar As New Collection

Public Sub MySub
  Dim MyVar As MyType
  MyVar.ID = 1
  MyVar.Name = "name"
  MyVar.MyInt = 2000

  ListVar.Add MyVar, MyVar.ID
End Sub
</code></pre>

<p>When trying to execute, I get a compile error: "Only user-defined types defined in public object modules can be coerced to or from a variant or passed to late-bound functions."</p>

<p>The goal would be to have a C# like List to which I can add MyType-objects and find them in a way you can do it in C#: ListVar.find(p => p.ID == 3).
Also if doable, the list should be persistent in the file. This is not needed because I could simply write it into a worksheet when closing and vice versa when opening.</p>

<p>Is there maybe a different object class I can use that fits my needs better?</p>