Deleting all duplicates but one in a single column

JamieDuncan

Board Regular
Joined
Aug 23, 2006
Messages
132
How would I go about Deleting all duplicates in a column except for the first entry of each value in that column, so that

A
A
A
A
A
B
B
B
B
C
C
C

would become

A
.
.
.
.
B
.
.
.
C
.
.

(full stops being blanks)
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Assuming that A2:A13 contains the data, try...

B2, copied down:

=IF(ISNA(MATCH(A2,A$1:A1,0)),A2,"")

Hope this helps!
 
Upvote 0
Code:
Sub ClearDupes()
With Range("A1", [a65536].End(xlUp))
    .AdvancedFilter Action:=xlFilterInPlace, Unique:=True
    .SpecialCells(xlCellTypeVisible).Select
    ActiveSheet.ShowAllData
    Selection.EntireRow.Hidden = True
    .SpecialCells(xlCellTypeVisible).ClearContents
    .Rows.Hidden = False
End With
End Sub
 
Upvote 0
I think even easier...
In B1: =A1
In B2 (and copied down): =IF(A2=A1,"",A2)

- If you actually want the dots in the matching cells as in your posted example then
in B2 & down: =IF(A2=A1,".",A2)
 
Upvote 0
How would I go about Deleting all duplicates in a column except for the first entry of each value in that column, so that

A
A
A
A
A
B
B
B
B
C
C
C

would become

A
.
.
.
.
B
.
.
.
C
.
.

(full stops being blanks)


Well...I aint an expert building Macros alike these MVPs but I can provide help in terms of a formula according to my caliber. U need to manually collate the data which would be very simple !

Assume ur data starts from A1

Use: if(countif(Range, A1)>1,"True", "False")

this will return "True" when a duplicate else will return false. Copy the data till last row and paste the same as values...Sort the data according to True and False !
 
Upvote 0
Thanks for your help all, should have mentioned I needed it to be in macro form, for an automated process.

Thanks Kris your code works perfectly :biggrin:
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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