Iterating Through the Elements of a Custom Collection: use the For...Each loop to iterate through the items in a collection
Sub IterateCollection()
Dim colNames As Collection
Dim varItem As Variant
Set colNames = New Collection
colNames.Add "A", "A"
colNames.Add "Dan", "Dan"
colNames.Add "Al", "Ale"
colNames.Add "B", "Bren"
colNames.Add "S", "Son"
colNames.Add "Sue", "Su"
For Each varItem In colNames
Debug.Print varItem
Next varItem
End Sub
Related examples in the same category