Duplicates

proficient

Well-known Member
Joined
Apr 10, 2012
Messages
745
Office Version
  1. 2016
Platform
  1. Windows
  2. Mobile
I want to find duplicates numbers in a range



Excel Workbook
ABCD
1114
2226
3343
44
56
61
72
82
94
1065
111
122
132
144
1525
161
172
Duplicates Value
 
I think you are looking for only duplicates number in one column eg. 1,2,4 etc. right?? or do you need the count also??
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
This might not be the cleanliest code but try:

Code:
Sub Duplicatevalues()Dim lr As Long, r As Long
lr = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For r = 1 To lr
      
    If Application.WorksheetFunction.CountIf(Range("A:A"), Range("A" & r)) > 1 Then Range("A" & r).Copy Destination:=Range("C" & ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row + 1)
Next r
ActiveSheet.Range("C:C").RemoveDuplicates Columns:=1, Header:=xlNo

End Sub
 
Upvote 0
It seems to working totally fine for the sample you gave. I rechecked. what is the error that you are getting?
 
Upvote 0
Try this: I have made some small changes. This uses Helper column as AA which will automatically get deleted in the end. But make sure you do not have any data there. If you do change the coloumn reference

Code:
Sub Duplicatevalues()
Dim lr As Long, r As Long
lr = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For r = 1 To lr
      Range("AA" & r).Value = Application.WorksheetFunction.CountIf(Range("A:A"), Range("A" & r))
    If Range("AA" & r).Value > 1 Then Range("A" & r).Copy Destination:=Range("C" & ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row + 1)
    
Next r
ActiveSheet.Range("C:C").RemoveDuplicates Columns:=1, Header:=xlNo
Columns("AA:AA").ClearContents
End Sub
 
Upvote 0
I want to find duplicates numbers in a range



Duplicates Value

ABCD
11 14
22 26
33 43
44
56
61
72
82
94
1065
111
122
132
144
1525
161
172

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"></colgroup><tbody>
</tbody>

Spreadsheet Formulas
CellFormula
D1=COUNTIF($A$1:$A$17,C1)
D2=COUNTIF($A$1:$A$17,C2)
D3=COUNTIF($A$1:$A$17,C3)

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

This seems to be what you are looking for:
Extract a list of duplicates from a column using array formula in excel | Get Digital Help - Microsoft Excel resource
 
Upvote 0
A possible solution using formulas

A B C D E
Numbers
DuplicatesList
Count
Duplicates
1
1
4
3
2
2
6
3
4
3
4
6
1
2
2
4
65
1
2
2
4
25
1
2

<TBODY>
</TBODY>


Formula in E2 to get the count of duplicates
=SUMPRODUCT(--(COUNTIF($A$2:$A$18,$A$2:$A$18)>1),--(MATCH($A$2:$A$18,$A$2:A18,0)=ROW($A$2:$A$18)-ROW($A$2)+1))

Array formula in C2
=IF($E$2>=ROWS($C$2:C2),INDEX(A:A,MIN(IF(COUNTIF($A$2:$A$18,$A$2:$A$18)>1,IF(ISNA(MATCH($A$2:$A$18,$C$1:C1,0)),ROW($A$2:$A$18))))),"")

confirmed with Ctrl+Shift+Enter
(hold down both Ctrl and Shift keys and hit Enter)

copy down

Formula in D2
=IF(C2<>"",COUNTIF(A:A,C2),"")

copy down

M.





 
Upvote 0
Proficient,

Try this code
Code:
Sub dups()
Dim c
With CreateObject("scripting.dictionary")
For Each c In Range("A1", Cells(Rows.Count, "a").End(3)).Value
    .Item(c) = .Item(c) + 1
Next
For Each c In .keys
    If .Item(c) = 1 Then .Remove c
Next
Range("C1").Resize(.Count, 2) = Application.Transpose(Array(.keys, .items))
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top