Create collection
Sub NewEmployees()
Dim colEmployees As New Collection
Dim emp As Variant
With colEmployees
.Add Item:="John Collins", Key:="128634456"
.Add Item:="Mary Poppins", Key:="223998765"
.Add Item:="Karen Loza", Key:="120228876", Before:=2
End With
For Each emp In colEmployees
Debug.Print emp
Next
MsgBox "There are " & colEmployees.Count & " employees."
End Sub
Related examples in the same category