Results 1 to 3 of 3

Thread: Code Fix to Delete Duplicates

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    The only problem I can see with your code without running it is that "For x = LastRow To 1" should read "For x = LastRow To 7."

    Anyway, try this version.

    Option Explicit
    
    Sub DeleteDups()
        Dim c As Long
        Dim MyRange As Range
        Set MyRange = Range("B7:B" & CStr(Cells(Rows.Count, 2).End(xlUp).Row))
        For c = MyRange.Cells.Count To 1 Step -1
        If Application.WorksheetFunction.CountIf(MyRange, _
            MyRange.Cells(c).Value) > 1 Then _
            MyRange.Cells(c).EntireRow.Delete
        Next c
    End Sub
    Last edited by Aussiebear; 12-04-2024 at 05:28 PM.
    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •