LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Count Duplicates

Hi, I have this code (not written by me) it counts duplicates just
fine
but the outcome looks like this...

Number Occurence
13113 4
13113 4
13113 4
13113 4
6626 3
6626 3
6626 3
etc

I would like it to look like this: Can any kind soul help out?

Number Occurence
13113 4
6626 3
etc

The code..

Public Sub a1a1a1()

Dim v As Variant, r As Range, i As Long, j As Long
Dim ThecellRange As Range
Dim startcell, endcell, clearrange As Range

Sheets("Locations").Select
Sheets("Locations").Range("A1").Select

On Error Resume Next
reallastrow = Cells.Find("*", Range("A1"), xlFormulas, , xlByRows,
xlPrevious).Row
reallastcol = Cells.Find("*", Range("A1"), xlFormulas, ,
xlByColumns, xlPrevious).Column

Set endcell = Cells(reallastrow, reallastcol)
Set startcell = Sheets("Locations").Range("C6")
Set ThecellRange = Range(startcell, endcell)

Set r = ThecellRange
v = r.Value
For i = 1 To UBound(v, 1)
For j = 1 To UBound(v, 2)
If Application.WorksheetFunction.CountIf(r, v(i, j)) 1 Then
r(i, j).Interior.ColorIndex = 6
Sheets("Locations").Range("A" & Rows.Count).End(xlUp).Offset(1,
0).Value = r(i, j)
Sheets("Locations").Range("B" & Rows.Count).End(xlUp).Offset(1,
0).Value = Application.WorksheetFunction.CountIf(r, v(i, j))
End If
Next j
Next i

End Sub

Cheers

Ste
 
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
Count duplicates once Tinkerbell1178 Excel Discussion (Misc queries) 2 December 1st 10 01:42 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 09:26 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"