Refer to an item in a collection using its unique key
Sub AccessCollection()
Dim colNames As Collection
Set colNames = New Collection
colNames.Add "A", "A"
colNames.Add "D", "Da"
colNames.Add "Al", "Al"
colNames.Add "Br", "Br"
colNames.Add "S", "So"
colNames.Add "Su", "Su"
Debug.Print colNames(1)
Debug.Print colNames.Item(1)
Debug.Print colNames("Alexis")
End Sub
Related examples in the same category