Can anyone see why this doesn't work?
I have a function (below), which loops through each row and then deletes if it finds a dupe, however for some reason it doesn't seem to work....
I have modified the code slightly, so that rather than deleting the row it simply inserts the word 'delete' in column A if the row is a dupe. This seems to work fine, so there must be something going wrong when it actually comes to deleting the cells or row (I have tried both ways, neither seems to work).
Public Function Delete_rows(row_start As Integer, column As Integer)
Dim row As Integer
Dim Row_count As Integer
row = row_start
Do Until Cells(row, column).Value = ""
If Cells(row, 1).Value = Cells(row + 1, 1).Value And Cells(row, 2).Value = Cells(row + 1, 2).Value And _
Cells(row, 3).Value = Cells(row + 1, 3).Value And Cells(row, 4).Value = Cells(row + 1, 4).Value And _
Cells(row, 5).Value = Cells(row + 1, 5).Value And Cells(row, 6).Value = Cells(row + 1, 6).Value And _
Cells(row, 7).Value = Cells(row + 1, 7).Value And Cells(row, 8).Value = Cells(row + 1, 8).Value Then
'ActiveSheet.Range(row & ":" & row).Delete
'ActiveSheet.Range("a" & row & ":h" & row).Delete Shift:=xlShiftUp
Cells(row, 1).Value = "DELETE"
'Cells(row, 1).EntireRow.Delete Shift:=xlShiftUp
End If
row = row + 1
Loop
Row_count = row
End Function
I have a function (below), which loops through each row and then deletes if it finds a dupe, however for some reason it doesn't seem to work....
I have modified the code slightly, so that rather than deleting the row it simply inserts the word 'delete' in column A if the row is a dupe. This seems to work fine, so there must be something going wrong when it actually comes to deleting the cells or row (I have tried both ways, neither seems to work).
Public Function Delete_rows(row_start As Integer, column As Integer)
Dim row As Integer
Dim Row_count As Integer
row = row_start
Do Until Cells(row, column).Value = ""
If Cells(row, 1).Value = Cells(row + 1, 1).Value And Cells(row, 2).Value = Cells(row + 1, 2).Value And _
Cells(row, 3).Value = Cells(row + 1, 3).Value And Cells(row, 4).Value = Cells(row + 1, 4).Value And _
Cells(row, 5).Value = Cells(row + 1, 5).Value And Cells(row, 6).Value = Cells(row + 1, 6).Value And _
Cells(row, 7).Value = Cells(row + 1, 7).Value And Cells(row, 8).Value = Cells(row + 1, 8).Value Then
'ActiveSheet.Range(row & ":" & row).Delete
'ActiveSheet.Range("a" & row & ":h" & row).Delete Shift:=xlShiftUp
Cells(row, 1).Value = "DELETE"
'Cells(row, 1).EntireRow.Delete Shift:=xlShiftUp
End If
row = row + 1
Loop
Row_count = row
End Function