View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Pat Jones Pat Jones is offline
external usenet poster
 
Posts: 6
Default finding duplicate cell and deleting both

Thanks;

That got rid of one each of the dupes, but I need to get rid of both copies
of each dupe. Can this macro be amended to do that ?


Pat


"ryguy7272" wrote in message
...
Sort the data and then run this macro:

Sub CheckForDupes()
Dim RowNdx As Long
Dim ColNum As Integer
ColNum = Selection(1).Column 'set number to match the proper column
For RowNdx = Selection(Selection.Cells.Count).Row To _
Selection(1).Row + 1 Step -1
If Cells(RowNdx, ColNum).Value = Cells(RowNdx - 1, ColNum).Value Then
Cells(RowNdx, ColNum).Delete shift:=xlUp
End If
Next RowNdx
End Sub


Warning!! Use this macro on a sample of your data; test it on a small
sample. If it doesn't do what you want post back. It is extremely
frustrating to accidentally delete data that you didn't really want to
delete.


Hope that helps,
Ryan---

--
RyGuy


"Pat Jones" wrote:

Hi;

I have about 8000 cells of which 800 are duplicates. I want to find all
the
dupes and delete BOTH copies of them. Can that be done and if so, how ?


Thanks;

Pat