In the following sample code, I am trying to demonstrate an issue .. which is simply to append to public collection
At the start of the code cols is declared as public so as to store all the items that will be generated through the PublicSub function
Code: Select all
Dim cols As Collection
Sub Test()
Dim e
For Each e In Array("A", "B")
Set cols = PublicSub(CStr(e))
Next e
End Sub
Function PublicSub(s As String) As Collection
Dim c As New Collection, i As Long
If s = "A" Then i = 1 Else i = 6
For i = i To i + 4
c.Add i
Next i
Set PublicSub = c
End Function