title: (Workaround Used) Excel VBA: Replacing a dictionary item in one class with a dictionary from a second class crashes Excel
body: <p>The issue I am having is with replacing an existing dictionary item with another dictionary pulled from a separate class.</p>
  
  <p>Here is the main line of code. Whenever I try to use this code, Excel crashes.</p>
  
  <pre><code>Call fileList.Items(i).updbrList(branchInfo)
  </code></pre>
  
  <p><code>fileList</code> is a dictionary, which stores an instance of a class, <code>fileInfo</code>.</p>
  
  <p>From multiple step-throughs of the code, I think it is because I'm not able to pass the <code>connList</code> dictionary correctly, because <code>branch.connList</code> remains empty in the <code>updbrList</code> sub, even after completing <code>Property Get</code>. </p>
  
  <p>The method <code>updbrList</code> is presented below. It collects a string <code>branchID</code> and a dictionary <code>connList</code> from the instance of another class, <code>branch</code>. I am trying to replace the current dictionary item <code>branch.brConn</code> with <code>branch.connList</code>.</p>
  
  <pre><code>'Class Module: File_Info
  Private pbranchList As Scripting.Dictionary`
  
  Private Sub Class_Initialize()
      Set pbranchList = New Scripting.Dictionary
  End Sub
  
  Public Sub addBranch(branch As Branch_Info)
      pbranchList.Add branch.branchID, branch.brConn
  End Sub
  
  Public Sub updbrList(branch As Branch_Info)
      pbranchList.Item(branch.branchID) = branch.connList
  End Sub
  </code></pre>
  
  <p>The properties for <code>connList</code> are presented below:</p>
  
  <pre><code>'Class Module: Branch_Info
  Private pconnList As Scripting.Dictionary
  
  'Declare variantcopy subroutine
  Private Declare Sub VariantCopy Lib "OleAut32" (pvarDest As Any, pvargSrc As Any)
  
  Private Function GetByRefVariant(ByRef var As Variant) As Variant
      VariantCopy GetByRefVariant, var
  End Function
  
  Private Sub Class_Initialize()
      Set pconnList = New Scripting.Dictionary
  End Sub
  
  Public Property Let connList(pconnListi As Variant)
      Set pconnList = pconnListi
  End Property
  Public Property Get connList() As Variant
      connList = GetByRefVariant(pconnList)
  End Property
  </code></pre>
  
  <p>Any help with this problem is much appreciated.
  Please ask for additional info, if required.</p>
  
  <p>Kind Regards,</p>
  
  <p>Eeshwar</p>