Iterate over VBA Dictionaries?
I'm using the Dictionary class in the MS Runtime Scripting library to store where labels are going to go for a report template. Is there a way to iterate over all the key value pairs in that dictionary like in Python?
I just want to use the key as the row number (It's all going in column A) and the value will be the label header.
Something like:
For Each key in dict
Range("A" & key).Value = dict(key)
Next key
Solution 1:
Try:
For Each varKey In oDic.Keys()
Range("A" & varKey).Value = oDic(varKey)
Next
Note that the key iterator must be declared as a Variant
.