Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve nth key in dictionary VBA

Is it possible to extract the nth key from a dictionary and its value in VBA? Something like

For i = 1 To Counter + diccompare.Count - UBound(RecSource)
WS.Cells(Lastrow + i, "A") = diccompare.Keys(UBound(RecSource) - Counter + i)
Next

Where I am trying to assign the Cell(Lastrow +i) the value of the key in dictionary diccompare(UBound(RecSource) - Counter + i)

like image 354
Vlad M Avatar asked Mar 09 '23 12:03

Vlad M


1 Answers

Not sure if I fully got you, something like this

Sub KeyTest()

Dim d As New Scripting.Dictionary

d.Add "Test1", 1
d.Add "Test2", 2
d.Add "Test3", 99

Debug.Print d.Keys()(1)

End Sub
like image 73
Nathan_Sav Avatar answered Mar 14 '23 19:03

Nathan_Sav