Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Counting Unique Records


I have a spreadsheet that includes a long list of reference numbers
(alphanumeric) in column A. These are in a random order and contain
many duplicates. I therefore wish to create a function that will count
the unique numbers for me.

I can do this by using advanced filter or by sorting and adding another
column to count when the reference changes, but do not want to change
the order of the data nor to have something that involves refiltering
every time. Ideally I need a formul;a that will allow an 'idiot user'
to see the count as they dynamically add or delete data.

Any thoughts would be gratefully received


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Counting Unique Records

Andy

You could download and install LaurentLongre's addin MOREFUNC.XLL
(it will give you similar functionality and a "few" more very usefull
functions. http://longre.free.fr/english/

If you want to write your own code following could be a start.
(note it doesnt distinguish between upper and lower case text items)
but it's reasonably fast. (Never as fast as compiled XLL's)


Function UniqueItemCount(rng As Range, _
Optional bExcludeBlank As Boolean = True) As Long

Dim rArea As Range
Dim rCell As Range
Dim cItem As Collection
Const x As Byte = 1

Set cItem = New Collection
On Error Resume Next
For Each rArea In rng.Areas
For Each rCell In rArea.Cells
cItem.Add x, CStr(rCell.Value2)
Next
Next

UniqueItemCount = cItem.Count

If bExcludeBlank Then
If Not IsError(cItem(vbNullString)) Then
UniqueItemCount = UniqueItemCount - 1
End If
End If

End Function



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


Andy wrote:


I have a spreadsheet that includes a long list of reference numbers
(alphanumeric) in column A. These are in a random order and contain
many duplicates. I therefore wish to create a function that will

count
the unique numbers for me.

I can do this by using advanced filter or by sorting and adding

another
column to count when the reference changes, but do not want to change
the order of the data nor to have something that involves refiltering
every time. Ideally I need a formul;a that will allow an 'idiot user'
to see the count as they dynamically add or delete data.

Any thoughts would be gratefully received


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Counting Unique Records


Problem solved. Thanks


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
Counting unique records in a field Loris Excel Discussion (Misc queries) 14 November 30th 08 04:55 PM
Counting unique records yhtak Excel Worksheet Functions 6 June 16th 06 02:34 PM
Counting unique records based on date range aspAddict Excel Worksheet Functions 3 October 26th 05 08:12 PM
Counting unique records with additional criteria [email protected] Excel Worksheet Functions 4 September 27th 05 06:53 PM
Counting Unique Records with multiple conditions Keithlearn Excel Worksheet Functions 4 April 27th 05 12:44 AM


All times are GMT +1. The time now is 01:42 PM.

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

About Us

"It's about Microsoft Excel"