title: VBA Class with Collection of itself
body: <p>I'm trying to create a class with a <code>Collection</code> in it that will hold other <code>CASN</code> (kind of like a linked list), I'm not sure if my instantiation of the class is correct. But every time I try to run my code below, I get the error</p>
  
  <blockquote>
    <p>Object variable or With block not set</p>
  </blockquote>
  
  <hr>
  
  <p><strong>CODE BEING RUN:</strong></p>
  
  <pre><code>If (Numbers.count &gt; 0) Then
     Dim num As CASN
     For Each num In Numbers
        If (num.DuplicateOf.count &gt; 0) Then   'ERROR HERE
           Debug.Print "Added " &amp; num.REF_PO &amp; " to list"
           ListBox1.AddItem num.REF_PO
        End If
     Next num
  End If
  </code></pre>
  
  <hr>
  
  <p><strong>CLASS - CASN:</strong></p>
  
  <pre><code>Private pWeek As String
  Private pVendorName As String
  Private pVendorID As String
  Private pError_NUM As String
  Private pREF_PO As Variant
  Private pASN_INV_NUM As Variant
  Private pDOC_TYPE As String
  Private pERROR_TEXT As String
  Private pAddressxl As Range
  Private pDuplicateOf As Collection
  
  
  
  '''''''''''''''' Instantiation of String, Long, Range etc.
  '''''''''''''''' Which I know is working fine
  
  
  ''''''''''''''''''''''
  ' DuplicateOf Property
  ''''''''''''''''''''''
  Public Property Get DuplicateOf() As Collection
     Set DuplicateOf = pDuplicateOf
  End Property
  Public Property Let DuplicateOf(value As Collection)
     Set pDuplicateOf = value
  End Property
  ''''' What I believe may be the cause
  </code></pre>
  
  <hr>
  
  <p>Basically what I've done is created two <code>Collection</code>s of class CASN and I'm trying to compare the two and see if there are any matching values related to the variable <code>.REF_PO</code> and if there is a match I want to add it to the <code>cthisWeek</code>'s collection of class <code>CASN</code> in the <code>DuplicateOf</code> collection of that class.</p>
  
  <p>Hopefully this make sense... I know all my code is working great up to this point of comparing the two <code>CASN</code> <code>Collection</code>'s. I've thoroughly tested everything and tried a few different approaches and can't seem to find the solution</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I found the error to my first issue but now a new issue has appeared... </p>