Need to know if I can delete repetitive cells


Posted by Sam on June 05, 2001 9:52 AM

I was wondering if there is an easy way to delete repetitive cells.
I need to delete about 25 sets of 100 rows. I was wondering if anyone know how to
remove the unneeded rows without having to delete them one by one.

Posted by Damon Ostrander on June 05, 2001 2:50 PM

Yes you can delete repetitive cells

Sam,

Here's a little macro that deletes all rows that have duplicate entries in the selected column. You must select a column or a column range. If you select a range that has multiple columns, it will just look at the first column.


Sub DeleteDuplicateRows()

' This macro deletes all rows on the active worksheet that
' have non-unique values in the selected column, including blanks.

Dim iRow As Long
Dim jRow As Long
Dim LastRow As Long
LastRow = Selection.Rows.Count
If ActiveSheet.UsedRange.Rows.Count < LastRow Then
LastRow = ActiveSheet.UsedRange.Rows.Count
End If
For iRow = LastRow To 1 Step -1
For jRow = 1 To iRow - 1
If Selection.Cells(iRow) = Selection.Cells(jRow) Then Rows(iRow).Delete
Next jRow
Next iRow

End Sub

Happy computing.

Damon



Posted by Sam on June 06, 2001 6:24 AM

Re: Yes you can delete repetitive cells

Thank you the Macro works great!