title: VBA create a nested dictionary
body: <p>I have the following set of code</p>
  
  <pre><code>Dim dic As Dictionary
  Dim dataArray() As Variant
  Dim headerRow(1 To 4) As Variant
  Dim mySheet As Worksheet
  Dim loopCounter As Long
  Dim endRow As Long
  Dim endColumn As Long
  Dim keyColumn As Long
  Dim x As Integer
  Dim wsName2 As String
  Dim duplicateDictionary As Dictionary
  
  wsName2 = ActiveSheet.Name
  Set duplicateDictionary = New Dictionary
  
  Set dic = New Dictionary
  
  With Worksheets(wsName2).Range("A1",Worksheets(wsName2).Range("A1").End(xlDown))
      keyColumn = 1
      endColumn = 4
      endRow = .Range("A1").End(xlDown).Row
      dataArray = Range(.Cells(1, 1), .Cells(endRow, endColumn)).Value
  End With
  
  For x = 1 To endColumn
      headerRow(x) = dataArray(1, x)
  Next x
  
  For loopCounter = 2 To endRow
      Dim storeKey As Variant
      Dim lineArray()
      Dim itemNumber As String
      Dim itemNumberAndDescription As String
      Dim q As Variant
  
      ReDim lineArray(1 To endColumn)
  
      For x = 1 To endColumn
          lineArray(x) = dataArray(loopCounter, x)
      Next x
  
      storeKey = lineArray(keyColumn)
  
      If Not dic.Exists(storeKey) Then
          dic.Add storeKey, New Collection
      End If
  
      'create duplicate dictionary if doesn't exist
      If Not duplicateDictionary.Exists(storeKey) Then
          duplicateDictionary.Add storeKey, New Dictionary
      End If
  
      dic(storeKey).Add lineArray
  
      itemNumber = UCase(Trim(Left(lineArray(2), InStr(1, lineArray(2), " -", vbBinaryCompare))))
  
      'add item in the duplicate dictionary based on the storekey
      duplicateDictionary(storeKey).Add itemNumber, itemNumber
  Next loopCounter
  </code></pre>
  
  <p>What i'm trying to do, using the list below as an example, is to create a nested dictionary and each with their own key. The purpose for this is because I have a report that will checks the dictionary created above for duplicate item before adding to it.</p>
  
  <p>City---Team</p>
  
  <p>LA  ----Lakers</p>
  
  <p>CHI ----Bulls</p>
  
  <p>NY  ----Knicks</p>
  
  <p>DAL ----Mavericks</p>
  
  <p>BOS ----Celtics</p>
  
  <p>I am able to create the first dictionary(city), but I can't seem to created a second (nested) dictionary for the team name based on the city. Help would be great. Thanks!</p>