Easy way to convert an Array to a Collection in VBA
"modern language" is where your problem lies - VBA/VB6 aren't really modern - neither have been advanced much for some years.
If you need to do it a lot, write a function to do the looping:
Sub AddAll(ByVal c as Collection, a as Variant) For Each item in a c.Add item Next itemEnd Sub
or if you want a new collection each time:
Function ToCollection(a as Variant) As Collection Dim c As New Collection For Each item in a c.Add item Next item Set ToCollection = cEnd Function
and then use it:
Dim c As New CollectionDim a(10) as Variant...AddAll c,a
or
Dim a(10) as VariantDim c as Collection...Set c = ToCollection(a)