+ Reply to Thread
Results 1 to 2 of 2

Thread: Can you Remove Both Duplicates?

  1. #1
    Registered User
    Join Date
    09-20-2011
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2010
    Posts
    20

    Question Can you Remove Both Duplicates?

    Hi Guys.

    I'm with a sheet and I need a way to remove BOTH duplicates. Meaning if 2 rows are identical I want both of them to be deleted, not just one. Say I want to do this for columns A:E, and I do have headers.

    Is there a way I can do this? Thanks for your help ahead of time.

  2. #2
    Valued Forum Contributor tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    USA
    MS-Off Ver
    Excel 2003 - 2007
    Posts
    2,352

    Re: Can you Remove Both Duplicates?

    mayhem12,

    Something like this?
    Sub tgr()
        
        With ActiveSheet.UsedRange
            With Cells(.Row, .Column + .Columns.Count).Resize(.Rows.Count)
                .Formula = "=ConcatRng(" & Range(Cells(.Row, ActiveSheet.UsedRange.Column), Cells(.Row, .Column - 1)).Address(0, 0) & ")"
                .Offset(0, 1).Formula = "=if(countif(" & .Address & "," & Cells(.Row, .Column).Address(0, 0) & ")>1,1,0)"
                .Offset(0, 1).AutoFilter 1, 1
                .Offset(1).EntireRow.Delete
                .Offset(0, 1).AutoFilter
                .Resize(, 2).EntireColumn.Delete
            End With
        End With
        
    End Sub
    
    Public Function ConcatRng(Rng As Range) As String
        
        Dim c As Range
        For Each c In Rng
            ConcatRng = ConcatRng & c.Value
        Next c
        
    End Function
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0