Advertisement
YasserKhalil2019

T3945_Remove Duplicates Keep Last Entry

Sep 19th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. https://excel-egy.com/forum/t3945
  2. ---------------------------------
  3.  
  4. Sub Remove_Duplicates_Keep_Last_Entry()
  5. Dim s As String, m As Long, r As Long
  6.  
  7. Application.ScreenUpdating = False
  8. s = Empty: m = Cells(Rows.Count, "C").End(xlUp).Row
  9.  
  10. For r = m To 2 Step -1
  11. If Application.CountIf(Range("C" & m & ":C" & r), Cells(r, 3).Value) <> 1 Then
  12. s = s & IIf(s <> Empty, ",", "") & Cells(r, 1).Address(0, 0)
  13. End If
  14. Next r
  15.  
  16. If s <> Empty Then
  17. Range(s).EntireRow.Delete
  18. End If
  19. Application.ScreenUpdating = True
  20. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement