Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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))



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Knowing the number sadman49 Excel Discussion (Misc queries) 2 March 9th 09 09:15 PM
How do I count the items in one column if another column is blank dereksmom Excel Worksheet Functions 1 November 8th 06 11:34 PM
how to calculate the number of non blank cells from any column? Mahesh Excel Worksheet Functions 2 August 8th 06 01:14 PM
Easiest way to delete blank cells in column (not entire row) sramsey Excel Discussion (Misc queries) 4 February 16th 06 04:28 PM
Delete Entire Row If Column C is Blank John Excel Programming 5 July 19th 04 10:23 PM


All times are GMT +1. The time now is 08:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"