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
Printable View
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
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
THANKS A LOT!!:)
Regards
vivek.s
You are welcome http://www.vbforums.com/images/ieimages/2004/12/1.gif