jpap1
10-23-2009, 04:00 AM
hi,
i have created a list where there are several cells that describe the item and am reading them into separate collections. The idea is that i then remove an item, put it into a new colelction and compare it to the old collection(from where it was removed to see if there are any others) and add the others to the new collection. for example say i ahve a list of 3 items (a, b, a) i want to add that to a collection with the end result being 2 new collections with one containing 2 lots of a and the other 1 lot of b
This is the code i have so far but im getting an error at 'ncrlist.add item' - im not sure why there is this error - although my memory of collections is quite rusty... could any one please shed some light?
many thanks
Sub abc()
Dim credit() As String
For i = 1 To 60000
If Range("credit").Offset(i, 0).Value = "" Then
counter = counter
Else
counter = counter + 1
End If
Next
ReDim credit(1 To counter)
For i = 1 To counter
credit(i) = Range("credit").Offset(i, 0).Value
Next
Dim creditlist As Collection, ncrlist as Collection
For i = 1 To counter
v = v + 1
creditlist.Add credit(i)
Next
For i = 1 To counter
Item = creditlist.Count
creditlist.Remove (Item)
ncrlist.Add Item
j = j + 1
If ncrlist(j) = creditlist(i) Then
creditlist.Remove (credit)
ncrlist.Add credit(i)
End If
Next
i have created a list where there are several cells that describe the item and am reading them into separate collections. The idea is that i then remove an item, put it into a new colelction and compare it to the old collection(from where it was removed to see if there are any others) and add the others to the new collection. for example say i ahve a list of 3 items (a, b, a) i want to add that to a collection with the end result being 2 new collections with one containing 2 lots of a and the other 1 lot of b
This is the code i have so far but im getting an error at 'ncrlist.add item' - im not sure why there is this error - although my memory of collections is quite rusty... could any one please shed some light?
many thanks
Sub abc()
Dim credit() As String
For i = 1 To 60000
If Range("credit").Offset(i, 0).Value = "" Then
counter = counter
Else
counter = counter + 1
End If
Next
ReDim credit(1 To counter)
For i = 1 To counter
credit(i) = Range("credit").Offset(i, 0).Value
Next
Dim creditlist As Collection, ncrlist as Collection
For i = 1 To counter
v = v + 1
creditlist.Add credit(i)
Next
For i = 1 To counter
Item = creditlist.Count
creditlist.Remove (Item)
ncrlist.Add Item
j = j + 1
If ncrlist(j) = creditlist(i) Then
creditlist.Remove (credit)
ncrlist.Add credit(i)
End If
Next