Number of different items in an entire column without knowing if s
it assigns the value in each cell to the collection and indexes it on the
value. If indexes are used (as I have) a collection doesn't allow duplicate
index values - so it raises and error rather than assign the value. The on
Error ignores the error and continues on. The end result is that the
collection nodupes holds a list of the unique entries in your range.
so you could also look at no dupes and see what the unique entries are as
shown in the code at the bottom:
Sub AB()
Dim nodupes As New Collection
Dim lastrow As Long
Dim numUnique As Long
Dim v As Variant, i As Long
Dim sStr As String
Dim itm As Variant
lastrow = Range("A3").End(xlDown).Row
Set rng = Range("A3:A" & lastrow)
v = rng
On Error Resume Next
For i = LBound(v) To UBound(v)
nodupes.Add v(i, 1), CStr(v(i, 1))
Next
On Error GoTo 0
numUnique = nodupes.Count
MsgBox "Number of Uniques: " & numUnique
sStr = ""
For Each itm In nodupes
sStr = sStr & itm & vbNewLine
Next
MsgBox sStr
End Sub
--
Regards,
Tom Ogilvy
wrote in message
oups.com...
Tom:
one more question, and apprecaite an answer, what is the following
syntax in your last code you sent me do?
nodupes.Add v(i, 1), CStr(v(i, 1))
|