ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Reset New Collection (https://www.excelbanter.com/excel-programming/291873-reset-new-collection.html)

Tony Di Stasi[_2_]

Reset New Collection
 
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!!

Chip Pearson

Reset New Collection
 
Tony,

Set the collection to Nothing. E.g.,

Set cTraders = Nothing


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Tony Di Stasi" wrote in message
...
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!!




Tom Ogilvy

Reset New Collection
 
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

--
Regards,
Tom Ogilvy


"Tony Di Stasi" wrote in message
...
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!!





All times are GMT +1. The time now is 06:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com