Macro to Delete Duplicate Cells

March 19th, 2010 - 10:40 am ET by MCRH | Report spam
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!
email Follow the discussionReplies 2 repliesReplies Make a reply

Similar topics

Replies

#1 Garys Student
March 19th, 2010 - 11:41 am ET | Report spam
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

Gary''s Student - gsnu201001


"MCRH" wrote:

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!
Replies Reply to this message
#2 MCRH
March 23rd, 2010 - 03:43 pm ET | Report spam
Works perfectly! This is exactly what I needed. Thank you so much!

"Gary''s Student" wrote:

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

Gary''s Student - gsnu201001


"MCRH" wrote:

> 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!
email Follow the discussion Replies Reply to this message
Help Create a new topicReplies Make a reply
Search Make your own search