Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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)) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Knowing the number | Excel Discussion (Misc queries) | |||
How do I count the items in one column if another column is blank | Excel Worksheet Functions | |||
how to calculate the number of non blank cells from any column? | Excel Worksheet Functions | |||
Easiest way to delete blank cells in column (not entire row) | Excel Discussion (Misc queries) | |||
Delete Entire Row If Column C is Blank | Excel Programming |