+ Reply to Thread
Results 1 to 5 of 5

How to transpose a column based on similar values

  1. #1
    Registered User
    Join Date
    12-19-2011
    Location
    Arizona
    MS-Off Ver
    Excel 2010
    Posts
    19

    How to transpose a column based on similar values

    I am trying to figure out how to transpose 1 column a data that I have that has groups of the same number in column A, such as:

    Column A Column B END RESULT in Column C
    2596 11 11,22,33
    2596 22
    2596 33
    2794 123 123,456,789,1011,1213
    2794 456
    2794 789
    2794 1011
    2794 1213

    Column C above is what I'm trying to achieve. Also, the rows do not really have to have a comma between each value, so if they have to be placed in separate cells down the row, then that will be fine. Any help with this would be greatly appreciated. Thanks.
    Last edited by tdunford7; 02-27-2012 at 11:39 PM.

  2. #2
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: How to transpose a column based on similar values

    check out this post from earlier today:

    http://www.excelforum.com/excel-2007...of-number.html
    If you liked my solution, please click on the Star -- to add to my reputation

    If your issue as been resolved, please clearly state so and mark the thread as [SOLVED] using the thread tools just above the first post.

  3. #3
    Registered User
    Join Date
    12-19-2011
    Location
    Arizona
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: How to transpose a column based on similar values

    That's not what I'm after. I've created a sample worksheet so you can see exactly so I don't have to try to explain it.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    12-19-2011
    Location
    Arizona
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: How to transpose a column based on similar values

    I've found the answer doing a little more digging here: http://www.excelforum.com/excel-prog...o-columns.html

    Thanks, StephenR!!!

  5. #5
    Registered User
    Join Date
    11-23-2011
    Location
    VietNam
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: How to transpose a column based on similar values

    Quote Originally Posted by tdunford7 View Post
    I've found the answer doing a little more digging here: http://www.excelforum.com/excel-prog...o-columns.html

    Thanks, StephenR!!!
    OhOh
    I'm writting code for you
    Try
    PHP Code: 
    Sub test()
    Dim sArrayRArrayiRow As LongAs Long
    Dim Dic 
    As Object
    Set Dic 
    CreateObject("Scripting.Dictionary")
    With Sheet1.Range("A1").CurrentRegion
        sArray 
    = .Value

    ReDim RArray
    (1 To UBound(sArray1), 1 To 255)
    For 
    iRow 1 To UBound(sArray1)
        If 
    Not Dic.exists(sArray(iRow1)) Then
            i 
    1iRow iRow
            Dic
    .Add sArray(iRow1), iRow
            RArray
    (iRow1) = sArray(iRow2)
            
    RArray(iRow255) = 1
        
    Else
            
    RArray(Dic.Item(sArray(iRow1)), 255) = RArray(Dic.Item(sArray(iRow1)), 255) + 1
            RArray
    (Dic.Item(sArray(iRow1)), RArray(Dic.Item(sArray(iRow1)), 255)) = sArray(iRow2)
        
    End If
    Next iRow

        
    .Offset(, 2).Resize(UBound(sArray), 254).Value RArray
    End With
    End Sub 
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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