SHARE
TWEET

T3945_Remove Duplicates Keep Last Entry

YasserKhalil2019 Sep 19th, 2019 (edited) 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top