excel vba collection to array code example
Example: vba array to collection
' Converts an array to a collection
Function ArrayToCollection(pArray As Variant) As Collection
Set ArrayToCollection = New Collection
Dim item As Variant
For Each item In pArray
ArrayToCollection.add item
Next item
End Function
' Adds a whole array to provided collection
Sub AddArrayToCollection(ByRef pCollection As Collection, pArray As Variant)
Dim item As Variant
For Each item In pArray
pCollection.add item
Next item
End Sub