title: Populate VBA Collection with Custom Objects using Collection.Add
body: <p>I am trying to add a custom object (Transaction) through the <code>sampleCollection.Add</code> from within a For loop.</p>
  
  <p>The code works if I add strings to the collection instead of objects.</p>
  
  <pre><code>Public Function PopCollection()
      Dim sampleCollection As New Collection
      Dim objTrans As New Transaction
      Dim objTrans2 As New Transaction
  
  
      '********** SETUP ARRAY FOR LOOP *************
      Dim arrA(0 To 1) As String
      arrA(0) = "Description 1"
      arrA(1) = "Description 2"
  
  
      '********** POPULATE COLLECTION *************
      For n = 0 To 1
          objTrans.DESC = arrA(n)
          Call sampleCollection.Add(objTrans)
      Next n
  
  
      '********** ITERATE THROUGH COLLECTION *************
      For n = 1 To sampleCollection.Count
          Set objTrans2 = sampleCollection.Item(n)
          Debug.Print n &amp; " - " &amp; objTrans2.DESC
      Next n
  
  End Function
  </code></pre>
  
  <p>The <code>Debug.Print n &amp; " - " &amp; objTrans2.DESC</code> line at the bottom of this code is outputting "Description 2" twice.  I want it to output "Description 1" and "Description 2".</p>
  
  <p>Here is the information in the Transaction class:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Public PTXN As Integer
  Public ACCTID As Integer
  Public CHECKNUM As String
  Public DESC As String
  Public STATUS As String
  Public TRANSACTIONDATE As String
  Public SPLIT_DESC As String
  Public SPLIT_AMT As Single
  Public SPLIT_CATEGORY As Integer
  </code></pre>
  
  <p>I only added the property declarations to the VB editor in Excel. I copy/pasted what was listed there.</p>