Results 1 to 4 of 4

Thread: duplicate rows in excel

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Resolved duplicate rows in excel

    hi,
    i have a excel with many rows....i have to make sure that no duplicate rows exist (assume there is only one column).........if it exists i have to delete that row........

    thanks and regards
    vivek.s
    Last edited by vivek.shankar; Dec 14th, 2004 at 01:53 PM.

  2. #2
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192

    Re: duplicate rows in excel

    I hope this helps you, it is a Macro I developed. You could try to adapt it to VB Code if you want to:

    Code:
     Sub DeleteDupes()
     '
     ' DeleteDupes Macro
     
     	Dim i As Integer
     	Dim j As Integer
     	Dim k As Integer
     	
     	Dim iDupe As Integer
     	Dim szDupes() As Integer
     	Dim bDupe As Boolean
     	
     	For i = 1 To Range("A1").SpecialCells(xlCellTypeLastCell).Row
     	 For j = 1 To i - 1
     	  bDupe = True
     	  For k = 1 To Range("A1").SpecialCells(xlCellTypeLastCell).Column
     	   If Cells(i, k).FormulaR1C1 <> Cells(j, k).FormulaR1C1 Then
     		bDupe = False
     		Exit For
     	   End If
     	  Next
     	  
     	  If bDupe Then
     	   ReDim Preserve szDupes(iDupe)
     	   szDupes(iDupe) = i
     	   iDupe = iDupe + 1
     	   Exit For
     	  End If
     	 Next
     	Next
     		
     	For i = UBound(szDupes) To 0 Step -1
     	 Rows(szDupes(i) & ":" & szDupes(i)).Delete Shift:=xlUp
     	Next
     End Sub
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: duplicate rows in excel

    THANKS A LOT!!

    Regards
    vivek.s

  4. #4
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192

    Re: duplicate rows in excel

    You are welcome
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width