I want create some objects of a user-defined class (clsDataSet) and put them into a collection. I.e. something like this:
Where clsDataSet.Initialise(ByVal RangeIn as Range) is a function that does various operations to fill the member variables of clsDataSet. The problem is that the objects are added to the collection by reference and so in each loop, every entry in the collection is changed as Series.Initialise() is called. Is there any way of getting round this or adding the objects by value?
Code:
Dim col As Range
Dim allDataPoints As New Collection
For Each col In RangeIn.Columns
Dim Series As New clsDataSet
Series.Initialise (col)
allDataPoints.Add Series
Next col