D
Dan
I'd welcome your assistance with a little probem I'm having with the
Collection object.
I'm trying to utilise the fact that the Collection item's key must be a
unique value to obtain a collection of unique items in a Collection object.
If a try to add an item that already exists then VBA throws an error which i
handle and proceed.
What i'd like to do though is maintain a count of the number of each unique
item so as to obtain frequency of each unique item.
To do this I'm trying to increment the value of the item of the collection
by one each time an error is thrown:
On Error Resume Next
For Each a In myRange
myCol.Add 1,a
If Err.Number <> 0 Then
'key exists so increment value by 1
myCol.Item(a) = myCol.Item(a)+ 1
End If
Err.Clear
Next a
On Error GoTo 0
They problem line of code is:
myCol.Item(a) = myCol.Item(a)+ 1
Does anyone know if i can actualy do what i'm trying to with the Collection
object?
Dan
Collection object.
I'm trying to utilise the fact that the Collection item's key must be a
unique value to obtain a collection of unique items in a Collection object.
If a try to add an item that already exists then VBA throws an error which i
handle and proceed.
What i'd like to do though is maintain a count of the number of each unique
item so as to obtain frequency of each unique item.
To do this I'm trying to increment the value of the item of the collection
by one each time an error is thrown:
On Error Resume Next
For Each a In myRange
myCol.Add 1,a
If Err.Number <> 0 Then
'key exists so increment value by 1
myCol.Item(a) = myCol.Item(a)+ 1
End If
Err.Clear
Next a
On Error GoTo 0
They problem line of code is:
myCol.Item(a) = myCol.Item(a)+ 1
Does anyone know if i can actualy do what i'm trying to with the Collection
object?
Dan