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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,696
Assuming that A2:A13 contains the data, try...

B2, copied down:

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

Hope this helps!
 

Krishnakumar

Well-known Member
Joined
Feb 28, 2003
Messages
2,615
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
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
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)
 

Stormseed

Banned
Joined
Sep 18, 2006
Messages
3,274
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 !
 

JamieDuncan

Board Regular
Joined
Aug 23, 2006
Messages
132
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:
 

Forum statistics

Threads
1,136,309
Messages
5,674,999
Members
419,541
Latest member
freddyboots

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
Top