Results 1 to 6 of 6

Thread: Removing Duplicate Entries in a Column

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Contributor Richie(UK)'s Avatar
    Joined
    May 2004
    Location
    UK
    Posts
    188
    Location
    Hi BM,

    Welcome to the board.

    OK, a few points:

    * How about using the 'unique' option in the Advanced Filter? Would that work for you?

    * Beware of the blanket use of 'On Error Resume Next' - those error messages could point you in the right direction for spotting the problem with your code.

    * When deleting rows its easy to lose track of the row that you are dealing with within a loop. For this reason its often easiest to establish the end of the range first and then loop backwards using Step-1. The idea is illustrated in this simple example:

    Sub Test()
        Dim i As Long
    Application.ScreenUpdating = False
        With Sheet1
        For i = .Cells(Rows.Count, "C").End(xlUp).Row To 2 Step -1
            If .Cells(i, "C").Value = "Mangoes" Then .Cells(i, "C").EntireRow.Delete
        Next i
        End With
        Application.ScreenUpdating = True
    End Sub
    HTH
    Last edited by Aussiebear; 04-29-2023 at 09:39 PM. Reason: Adjusted the code tags

Posting Permissions

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