+ Reply to Thread
Results 1 to 8 of 8

identifying unique data from 2 columns

  1. #1
    Forum Contributor
    Join Date
    05-13-2019
    Location
    Halifax, Canada
    MS-Off Ver
    2016
    Posts
    176

    identifying unique data from 2 columns

    Hi all,

    I have got 2 sets of numeric data in 2 columns:

    Column A Column B Column C (desired result) Column D (desired result)
    001 002 001 A
    002 003 004 A
    003 005 005 B
    004 006 007 A
    006 008 008 B
    007 009 015 A
    009 016 A
    015
    016

    I am looking to identify number in Column C that is Unique and write a comment "Column Name" (to which Column data set the unique data belongs) in Column D. Appreciate your help for excel formula and/or VBA code.

    Thank you
    Roshan Shakya

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this !


    A demonstration as a beginner starter :

    PHP Code: 
    Sub Demo1()
               
    Dim VS$(), Rg As RangeR&
                   
    = [{"A","B"}]
        
    With [A1].CurrentRegion.Columns("A:B")
               .
    Offset(, 2).Clear
                ReDim S
    (1 To .Cells.Count1)
            For 
    Each Rg In .SpecialCells(xlCellTypeConstants)
                If 
    Application.CountIf(.CellsRg.Value2) = 1 Then
                    R 
    1
                    S
    (R0) = Rg.Value2
                    S
    (R1) = V(Rg.Column)
                
    End If
            
    Next
        End With
            
    If R Then [C1:D1].Resize(R).Value2 S
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 08-07-2019 at 05:25 PM. Reason: optimization following post #4 …

  3. #3
    Forum Contributor
    Join Date
    05-13-2019
    Location
    Halifax, Canada
    MS-Off Ver
    2016
    Posts
    176

    Re: Hi ! Try this !

    That was awesome. Thanks Marc L.

  4. #4
    Forum Contributor
    Join Date
    05-13-2019
    Location
    Halifax, Canada
    MS-Off Ver
    2016
    Posts
    176

    Re: identifying unique data from 2 columns

    Hi Marc L,

    There is a minor problem. If Columns A and B has the exact same values then there is a Run-Time Error 1004.

    Thank you
    Roshan Shakya

  5. #5
    Registered User
    Join Date
    07-21-2019
    Location
    Italy
    MS-Off Ver
    2016
    Posts
    58

    Re: identifying unique data from 2 columns

    Hi,
    i propose an alternative to the Mark code:
    Please Login or Register  to view this content.
    Last edited by MrGes; 08-07-2019 at 05:24 PM.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    Thanks guys for the rep' !

    Quote Originally Posted by Roshan.Shakya View Post
    If Columns A and B has the exact same values then there is a Run-Time Error 1004.
    As it's what could occur without any attachment so without any test !
    Anyway I just amend the demonstration in post #2 …
    Last edited by Marc L; 08-07-2019 at 06:32 PM.

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Lightbulb

    Another way in order to keep the text cell formatting and the column order :

    PHP Code: 
    Sub Demo2()
            
    Dim F$, C%, VR&
                
    Application.ScreenUpdating False
        With 
    [A1].CurrentRegion.Columns("A:B")
               .
    Item("C:D").Clear
                F 
    "TRANSPOSE(IF(COUNTIF(" & .Address ",#)=1,ROW(#)))"
            
    For 1 To 2
                
    For Each V In Filter(Evaluate(Replace(F"#", .Item(C).Address)), FalseFalse)
                    
    1
                    Cells
    (VC).Copy Cells(R3)
                    
    Cells(R4).Value2 Chr$(64 C)
                
    Next
            Next
        End With
                Application
    .ScreenUpdating True
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  8. #8
    Forum Contributor
    Join Date
    05-13-2019
    Location
    Halifax, Canada
    MS-Off Ver
    2016
    Posts
    176

    Re: identifying unique data from 2 columns

    Thanks Marc, it worked!!!!

+ 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. Replies: 4
    Last Post: 02-14-2019, 10:38 AM
  2. [SOLVED] Identifying unique data from multiple columns/rows
    By Paddymaw in forum Excel General
    Replies: 3
    Last Post: 02-12-2019, 09:08 AM
  3. Replies: 1
    Last Post: 03-28-2017, 03:50 AM
  4. Replies: 11
    Last Post: 12-17-2015, 11:34 AM
  5. Identifying and summing sections of columns with identical data?!?
    By Tilly13 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-16-2013, 03:18 PM
  6. [SOLVED] Identifying duplicate data using multiple columns
    By DuckMan72 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-13-2013, 05:28 PM
  7. Identifying an item with data in two columns
    By BaileyWinston in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-23-2010, 11:52 AM

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