+ Reply to Thread
Results 1 to 3 of 3

Quite a puzzler - Concatenate for unique entries

Hybrid View

  1. #1
    Registered User
    Join Date
    04-15-2011
    Location
    Bucharest
    MS-Off Ver
    Excel 2007
    Posts
    2

    Unhappy Quite a puzzler - Concatenate for unique entries

    Hello,

    Presenting below quite a puzzler

    I have the following info on 3 columns; i am really curios if i can get the result mentioned below (meaning put the info on column 3 in a single cell where the first two cells have the same info - meaning for the unique two first column which i already have i need to write A,B,C or D,E,F next to them, as in the result)

    Is it really possible? Couldn't figure out any solution for this

    ARRAY:


    Word 1|Opt 1|A
    Word 1|Opt 1|B
    Word 1|Opt 1|C
    Word 2|Opt 2|D
    Word 2|Opt 2|E
    Word 2|Opt 2|F

    Result
    Word 1|Opt 1|A, B, C
    Word 2|Opt 2|D, E, F

  2. #2
    Valued Forum Contributor jwright650's Avatar
    Join Date
    12-10-2010
    Location
    Va, USA
    MS-Off Ver
    Excel 2003, Excel 2010
    Posts
    606

    Re: Quite a puzzler - Concatenate for unique entries

    Is this what you are trying to do? See the formula in the cells in Column E
    Attached Files Attached Files
    Life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
    John Wright

  3. #3
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Quite a puzzler - Concatenate for unique entries

    Hi despacos
    welcome to the forum,

    on the sample...
    Sub ptest()
        Dim a, b(), i!, n!
        With Range("a1", Range("a" & Rows.Count).End(xlUp)).Resize(, 3)
            a = .Value
            ReDim b(1 To UBound(a, 1), 1 To 3)
            With CreateObject("Scripting.Dictionary")
                .CompareMode = vbTextCompare
                For i = 1 To UBound(a, 1)
                    If Not .exists(a(i, 1)) Then
                        n = n + 1
                        b(n, 1) = a(i, 1)
                        b(n, 2) = a(i, 2)
                        .Add a(i, 1), n
                    End If
                    b(.Item(a(i, 1)), 3) = b(.Item(a(i, 1)), 3) & IIf(b(.Item(a(i, 1)), 3) <> "", ", ", " ") & a(i, 3)
                Next
            End With
            .ClearContents
        End With
        Range("a1").Resize(n, 3).Value = b
    End Sub
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

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