|
-
Dec 13th, 2004, 07:09 PM
#1
Thread Starter
Fanatic Member
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.
-
Dec 14th, 2004, 01:30 PM
#2
Frenzied Member
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
-
Dec 14th, 2004, 01:53 PM
#3
Thread Starter
Fanatic Member
Re: duplicate rows in excel
THANKS A LOT!!
Regards
vivek.s
-
Dec 14th, 2004, 02:21 PM
#4
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|