Hello
I have a problem with my vba collection object. When I run the code below I get the "out of stack space (error 28)" message. It seems to me that my collection shouldnt take up so much memory as the each object in it is just a set of a string and 3 single values. Yet it does. The code works fine if I eliminate ie two properties from the Pik object.
Please let me know how to overcome this.
Sub Purity()
Dim All As Range, Some As Range
Dim a As Integer, b As Integer
Dim Peak As New Pik
Dim Piks As New Collection
Set All = Range(Cells(1, 1), Cells.SpecialCells(xlCellTypeLastCell))
Set Some = FindThem(All, 2, "vial", True)
'FindThem is a function that returns a certain range
For Each cell In Some
b = cell.Row
Peak.RetTime = Cells(b, 6)
Peak.Name = Cells(b, 5)
Peak.Area = Cells(b, 7)
Peak.AreaPcent = Cells(b, 8)
Piks.Add Item:=Peak
Set Peak = Nothing
Next cell
End Sub
Pik class moudle
Private pName As String
Private pRetTime As Single
Private pArea As Single
Private pAreaPcent As Single
Public Property Get Name() As String
Name = pName
End Property
Public Property Let Name(Value As String)
pName = Value
End Property
Public Property Get RetTime() As Single
RetTime = pRetTime
End Property
Public Property Let RetTime(Value As Single)
pRetTime = Value
End Property
Public Property Get Area() As Single
Area = pArea
End Property
Public Property Let Area(Value As Single)
Area = Value
End Property
Public Property Get AreaPcent() As Single
AreaPcent = pAreaPcent
End Property
Public Property Let AreaPcent(Value As Single)
AreaPcent = Value
End Property