How to deleted duplicate record on columnA

G

Guest

I have big excel record, but on the columnA has a lots of dupluicate record,
how can I write a macro to delete them
ColumnA
aaa
aaa
bbb
bbb
ccc
ccc
I want be like this
ColumnA
aaa
bbb
ccc


Thanks.

Lillian
 
G

Guest

Sub sonic()
i = Cells(Rows.Count, "A").End(xlUp).Row
For j = i To 2 Step -1
If Cells(j, "A").Value = Cells(j - 1, "A").Value Then
Cells(j, "A").Delete
End If
Next
End Sub
 
G

Guest

Gary,

This look good, but only deleted columnA, but actually I would like
deleted entire duplicated record, how did we do that.


Thanks for all the help

Lillian
 
G

Guest

Sub sonic()
i = Cells(Rows.Count, "A").End(xlUp).Row
For j = i To 2 Step -1
If Cells(j, "A").Value = Cells(j - 1, "A").Value Then
Cells(j, "A").EntireRow.Delete
End If
Next
End Sub

The one-line change deletes the row instead of just the cell.
 
G

Guest

Thanks Gary, this one work

Gary''s Student said:
Sub sonic()
i = Cells(Rows.Count, "A").End(xlUp).Row
For j = i To 2 Step -1
If Cells(j, "A").Value = Cells(j - 1, "A").Value Then
Cells(j, "A").EntireRow.Delete
End If
Next
End Sub

The one-line change deletes the row instead of just the cell.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top