title: Setting a global Scripting.Dictionary in Visual Basic for Applications (VBA)
body: <p>I have a function that is appending a dictionary. I want to keep the contents of this dictionary as long as the <code>updateList</code> isn't true. I currently have it setup like this:</p>
  
  <pre><code>Public Function runPolluxFull(voerUit As Boolean, updateList As Boolean)
  
  Dim dicTitle As Variable
  Dim dicFound As Variable
  
  If updateList = True Then
  Set dicTitle = CreateObject("Scripting.Dictionary")
  Set dicFound = CreateObject("Scripting.Dictionary")
  
  While status
          Set ObjectsJSON = jsonlibPollux.parse(responseString)
  
          With dicTitle
          .Add inc, ObjectsJSON.Item("title")
          End With
  
          With dicFound
          .Add inc, ObjectsJSON.Item("description")
          End With
  
  Wend
  End If
  </code></pre>
  
  <p>And when <code>voerUit</code> is true the following happens:</p>
  
  <pre><code>For i = 1 To dicTitle.Count
  klaar = findReplace(dicTitle.Item(i), "x" + dicTitle.Item(i), dicTitle.Item(i) + vbCrLf + vbCrLf + dicFound.Item(i))
  Next i
  </code></pre>
  
  <p>The problem here is that when this function ends, <code>dicTitle</code> and <code>dicFound</code> are cleared, and the <code>findReplace</code> function gets fed empty arguments.</p>
  
  <p>Is there anyway to makes to code work, or a good workaround? </p>