Reset New Collection

  • Thread starter Thread starter Tony Di Stasi
  • Start date Start date
T

Tony Di Stasi

Created a collection and will need to reset it to zero
once it has been compiled so that it can be compiled with
other data.

Dim cTraders As New Collection

On Error Resume Next
For Each rCell In Range(Cells(65536, 1).End(xlUp), Cells
(2, 1))
cTraders.Add rCell.Value, rCell.Value
Next rCell
On Error GoTo 0

I need a line here to reset the collection to zero so that
when i move on the next worksheet the collection will be
different. Thanks!!
 
Tony,

Set the collection to Nothing. E.g.,

Set cTraders = Nothing


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Sub AAA()

Dim cTraders As New Collection

On Error Resume Next
For Each rCell In Range(Cells(65536, 1).End(xlUp), Cells(2, 1))
cTraders.Add rCell.Value, rCell.Value
Next rCell
On Error GoTo 0
Debug.Print cTraders.Count
For i = 1 To cTraders.Count
cTraders.Remove cTraders.Item(1)
Next
Debug.Print cTraders.Count
End Sub
 
Back
Top