What I am trying to achieve is to create a vba code to completely delete the rows if the value in column C (Id) is unique. So in example below the rows 6 and 7 would be deleted since the 111115 and 111116 are not showing up more than once in this column C. Any help is welcome! Thanks a lot.
Code so far: (but not working yet)
Sub delete_not_duplicates()
Dim i As Integer, j As Integer, toDel As Boolean, theNum As Integer
i = 2
Do While Cells(i, 3).Value <> ""
toDel = True
theNum = Cells(i, 3).Value
Do While Cells(j, 3).Value <> ""
If i <> j and Cells(j, 3) == theNum Then
toDel = False
Loop
If toDel == true Then
Rows(i).Delete
Else
i = i + 1
End If
Loop
End Sub
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…