+ Reply to Thread
Results 1 to 8 of 8

Unique values for multiple columns

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-09-2011
    Location
    Perth, Australia
    MS-Off Ver
    2016
    Posts
    161

    Unique values for multiple columns

    Hi,

    If I have multiple columns of data, with duplicate values in Column A, is it possible to remove all rows that have a “duplicate” in Column A and still show all columns?

    I want to show all the unique values in column A, and the associated data in the other columns.

    Other methods of getting unique values that I have tried seem to only work for a single column (e.g. Data, Advanced, Unique records only).

    Please see attached example.

    Thanks very much

    Dave
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Unique values for multiple columns

    Use remove duplicate function in excel

  3. #3
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Unique values for multiple columns

    @AB33

    "Use remove duplicate function in excel"

    I believe the OP is using 2003.

    @motox

    You say that the duplicates are in column A only? From your data, they would appear to be across all columns?

    Regards
    Last edited by XOR LX; 08-28-2013 at 05:05 AM.
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Unique values for multiple columns

    Sub M_snb()
       Sheet1.Cells(1).CurrentRegion.AdvancedFilter 2, , Sheet2.Cells(1), True
    End Sub



  5. #5
    Forum Contributor satputenandkumar0's Avatar
    Join Date
    11-08-2012
    Location
    Pune, India
    MS-Off Ver
    Office xp & Office 2007
    Posts
    398

    Re: Unique values for multiple columns

    Dear Motox,

    try below code

    Sub RemoveDuplicate()
        Dim rCell As Range
        Dim rRange As Range
        Dim lCount As Long
        Application.ScreenUpdating = False
        Set rRange = Range("A1", Range("A" & Rows.Count).End(xlUp))
        lCount = rRange.Rows.Count
        For lCount = lCount To 1 Step -1
            With rRange.Cells(lCount, 1)
                If WorksheetFunction.CountIf(rRange, .Value) > 1 Then
                    .EntireRow.Delete
                End If
            End With
        Next lCount
    End Sub
    Regards,
    Nandkumar S
    Regards,
    Nandkumar S.
    ---------------------------------------------------------------
    Don't forget to Click on * if you like my solution.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Unique values for multiple columns

    XOL,
    Thank you!
    I did not notice OP's profile.
    Advance filter is faster than any code.

    Sub removeme()
     With ActiveSheet
        .Range("A2:C" & .Cells(.Rows.Count, 1).End(xlUp).Row).RemoveDuplicates 1
       End With
    End Sub

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Unique values for multiple columns

    Quote Originally Posted by AB33 View Post
    XOL,
    Thank you!
    I did not notice OP's profile.
    Advance filter is faster than any code.

    Sub removeme()
     With ActiveSheet
        .Range("A2:C" & .Cells(.Rows.Count, 1).End(xlUp).Row).RemoveDuplicates 1
       End With
    End Sub
    No advanced filter in your code though....

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Unique values for multiple columns

    Well,
    Obviously, I was referring to your code as post # 4 seems to be the only one with "That magic word".

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Count unique values across 2 columns with multiple criteria
    By Skywalker01 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-29-2012, 08:04 AM
  2. Replies: 16
    Last Post: 01-11-2012, 10:51 AM
  3. Replies: 5
    Last Post: 04-21-2011, 05:22 PM
  4. Replies: 1
    Last Post: 03-02-2011, 04:14 PM
  5. Replies: 7
    Last Post: 07-13-2009, 01:30 PM

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.6.0 RC 1