Delete repeated values

A

Aladino

Hi,

I need to delete the repeated data but all of it. I´ve tried to use a
filter but it doesn´t work because the repeated data stays. Example:

1
2
3
3

After runnig the macro or filter sholud appear this

1
2


Hope u can help. Thanks
 
D

Don Guillett

This will work for the example provided.

Sub deletealldups()
mc = 1 ' column A
On Error Resume Next
For i = Cells(Rows.Count, mc).End(xlUp).Row To 1 Step -1
If Cells(i - 1, mc) = Cells(i, mc) Then
Rows(i - 1).Resize(2).Delete
End If
Next i
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
Hi,

I need to delete the repeated data but all of it. I´ve tried to use a
filter but it doesn´t work because the repeated data stays. Example:

1
2
3
3

After runnig the macro or filter sholud appear this

1
2


Hope u can help. Thanks
 
D

Don Guillett

This will delete for all duplicates if the count is more than 1

Sub deletealldups()
mc = 1 ' column A
On Error Resume Next
For i = Cells(Rows.Count, mc).End(xlUp).Row To 1 Step -1
numtogo = Application.CountIf(Columns(mc), Cells(i, mc))
If numtogo > 1 Then
Rows(i - numtogo + 1).Resize(numtogo).Delete
End If
Next i
End Sub
 

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