Hi
I can print Dictionary values to the immediate window by running the code below, but I wanted to know how I print "all" the Dictionary values into an Excel sheet?
Thanks
I can print Dictionary values to the immediate window by running the code below, but I wanted to know how I print "all" the Dictionary values into an Excel sheet?
Code:
Public Sub DictionaryExamples()
Dim exampleValues As Variant
Dim i As Long
Dim aKey As String
Dim aValue As Integer
Dim bValue As String
Dim exampleDict As Object
'Load values into a variant array
exampleValues = Range("A1:C12").Value
'Instantiate a dictionary
Set exampleDict = CreateObject("scripting.dictionary")
'Read all keys and values, and add them to the dictionary
For i = 1 To UBound(exampleValues)
aKey = CStr(exampleValues(i, 1))
aValue = CInt(exampleValues(i, 2))
bValue = CStr(exampleValues(i, 3))
exampleDict.Add aKey, Array(aValue, bValue)
Debug.Print aKey, aValue, bValue
Next i
End Sub
Thanks
Last edited: