title: key value pair, loop through a dictionary vba
body: <p>I am trying to read a column one cell at a time and store it the cell as a key and its frequency as its value. Then I want to place all key-value pairs into a range say column P and Q. I think I got the first part of the job done with the code below (not 100% on it though) Now how can place the key value pairs to a range?</p>
  
  <pre><code>Dim D As Dictionary
  Set D = New Dictionary
  Dim DR As Range
  
  
   Set DR = Range(Cells(2, 2), Cells(2, 2).End(xlDown))
  
      For Each Cell In DR.Cells
  
          If Not D.Exists(Cell.Value) Then
          D.Add Cell, 1
          Else
          D.Exists (Cell.Value)
          D.Item(Cell.Value) = D.Item(Cell.Value) + 1
          End If
  
      Next Cell
  </code></pre>
  
  <p>I roughly have the idea of looping through the dictionary per each key but I cant do</p>
  
  <pre><code>Dim k as key
  </code></pre>
  
  <p>any help is much appreciated</p>