Macro to Delete Duplicate Cells

M

MCRH

Hi,

I've seen other questions regarding deleting duplicates but none of them
quite fit what I need.

I have values in column A. I want to delete the cell (shift up) of any and
all exact duplicates, but keep the original.

Thanks for your help!
 
G

Gary''s Student

Try:

Sub CleanA()
Dim n As Long
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = n To 2 Step -1
m = Application.WorksheetFunction.CountIf(Range("A1:A" & i), Range("A" &
i).Value)
If m > 1 Then
Range("A" & i).Delete Shift:=xlUp
End If
Next
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