
Originally Posted by
sheeeng
well done,xld.
but you had delete some with different data.
eg.
A B C Column
1 2 3
1 2 <-these u had deleted
1 3 <-by right, should not be deleted, because no identical rows found.
2 3
3 4 5
Sorry about the crappy testiung. Is this better
Sub DeleteRows()
Dim iLastRow As Long
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("G1").Value = "1"
Range("G2").Value = "2"
Range("G1:G2").AutoFill Destination:=Range("G1:G" & iLastRow)
Columns("A:F").Sort Key1:=Range("D1"), _
Order1:=xlAscending, _
Key2:=Range("E1"), _
Order2:=xlAscending, _
Key3:=Range("F1"), _
Order3:=xlAscending, _
Header:=xlNo
Columns("A:F").Sort Key1:=Range("A1"), _
Order1:=xlAscending, _
Key2:=Range("B1"), _
Order2:=xlAscending, _
Key3:=Range("C1"), _
Order3:=xlAscending, _
Header:=xlNo
Columns("H").Insert
Range("H1").Formula = _
"=SUMPRODUCT(--($A$1:A1&$B$1:B1&$C$1:C1&$D$1:D1&$E$1:E1&$F$1:F1=A1&B1&C1&D1&E1&F1))>1"
Range("H1").AutoFill Destination:=Range("H1:H" & iLastRow), Type:=xlFillDefault
Rows("1:1").EntireRow.Insert
Range("H1").Value = "Temp"
Columns("H:H").AutoFilter Field:=1, Criteria1:="TRUE"
Rows("1:" & iLastRow + 1).SpecialCells(xlCellTypeVisible).Delete
Columns("A:G").Sort Key1:=Range("G1"), _
Order1:=xlAscending, _
Header:=xlNo
Columns("G:G").ClearContents
End Sub