I have a Dictionary which has school names as keys and arrays for values. Once the addition of the key,value pairs to the dictionary is done, I want to be able to update the values of the array after checking if certain conditions are met. However, the values don't get updated even if the conditions are met. Any thoughts?
Dim nre(0 To 2) As Boolean
nre(0) = False
nre(1) = False
nre(2) = False
Dim schdict
Set schdict = CreateObject("Scripting.Dictionary")
For i = 2 To numrows
schname = ActiveSheet.Cells(i, schnamecolumn).Value
category = ActiveSheet.Cells(i, categorycolumn).Value
If schdict.Exists(schname) = False Then
schdict.Add schname, nre
End If
If category = "New Placement" Then
schdict.Item(schname)(0) = True
ElseIf category = "Renomination" Then
schdict.Item(schname)(1) = True
Else
schdict.Item(schname)(2) = True
End If
Next i
MsgBox schdict.Item("Division 01")(0)
Try this:
Create a second array:
Dim vArray as variant
redim vArray(0 to 2)
Then assign the dictionary array to the newly created array as such:
vArray = schdict.Item(schname)
Set the value of the array:
vArray(1) = True
And finally assign the array to the dictionary item:
schdict.Item(schname) = vArray
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With