Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Count duplicates needed

I have a list of names starting in R3C1 that may contain
duplicate names in column 1 only. I need some help with
the code to search all cells starting at R3C1 until the
names end, tally the count of duplicate names and put the
result in R3C4.
Thank you very much for your help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Count duplicates needed

Hi

If I have understood how you want to count things, then this should give you the count. Assume that the data is a,a,b,b then the output you would want is 2 (ie there are 2 duplicate names). Similarly if the data is a,a,b,b,b then the result is 3.

Tony

Sub aaa()

Dim nodupes As New Collection
countall = 0
Range("a3").Select
On Error Resume Next
While Not IsEmpty(ActiveCell)
nodupes.Add ActiveCell.Value, CStr(ActiveCell.Value)
countall = countall + 1
ActiveCell.Offset(1, 0).Select
Wend
On Error GoTo 0

Range("D3").Value = countall - nodupes.Count

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Count duplicates needed

This comes close but not quite..

Mike H
Mike H
Jim B
Jim B
Jim B
Bill C
Tom R
Tom R

The result I would want is Mike H is duplicated once, Jim
B duplicated twice, Tom R duplicated once so I have 3
duplicates. The other option would be to count only
unique names..

If I can get help with code both ways I would be estatic..
Thank you.
-----Original Message-----
Hi

If I have understood how you want to count things, then

this should give you the count. Assume that the data is
a,a,b,b then the output you would want is 2 (ie there are
2 duplicate names). Similarly if the data is a,a,b,b,b
then the result is 3.

Tony

Sub aaa()

Dim nodupes As New Collection
countall = 0
Range("a3").Select
On Error Resume Next
While Not IsEmpty(ActiveCell)
nodupes.Add ActiveCell.Value, CStr(ActiveCell.Value)
countall = countall + 1
ActiveCell.Offset(1, 0).Select
Wend
On Error GoTo 0

Range("D3").Value = countall - nodupes.Count

End Sub

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Count duplicates needed

The code I gave you will give a list of unique names ( the collection nodupes). You could loop through that collection to print out a list of the unique values.

Similarly, you could use that to get the name, and then do a countif to get the number of times that name appears. Take 1 from that count and you will get the name and the number of duplicates.

The while - wend section builds the list of unique names.

You can loop through that in the form

for each item in nodupes

next item

the variable item will give the value of the name and it can be used in a countif function.


Tony

----- wrote: -----

This comes close but not quite..

Mike H
Mike H
Jim B
Jim B
Jim B
Bill C
Tom R
Tom R

The result I would want is Mike H is duplicated once, Jim
B duplicated twice, Tom R duplicated once so I have 3
duplicates. The other option would be to count only
unique names..

If I can get help with code both ways I would be estatic..
Thank you.
-----Original Message-----
Hi
If I have understood how you want to count things, then

this should give you the count. Assume that the data is
a,a,b,b then the output you would want is 2 (ie there are
2 duplicate names). Similarly if the data is a,a,b,b,b
then the result is 3.
Tony
Sub aaa()
Dim nodupes As New Collection

countall = 0
Range("a3").Select
On Error Resume Next
While Not IsEmpty(ActiveCell)
nodupes.Add ActiveCell.Value, CStr(ActiveCell.Value)
countall = countall + 1
ActiveCell.Offset(1, 0).Select
Wend
On Error GoTo 0
Range("D3").Value = countall - nodupes.Count
End Sub
.


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
Don't Count Duplicates Johnny Excel Discussion (Misc queries) 2 April 24th 10 06:39 PM
Count Duplicates saman110 via OfficeKB.com Excel Discussion (Misc queries) 5 September 27th 07 06:04 PM
Count Employee Work Time - Don't Count Duplicates J Excel Worksheet Functions 3 May 1st 07 10:47 PM
Count Duplicates Jonathan Excel Discussion (Misc queries) 2 April 8th 05 03:23 PM
count a group of numbers but do not count duplicates Lisaml Excel Worksheet Functions 2 January 26th 05 11:19 PM


All times are GMT +1. The time now is 03:57 AM.

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"