Consulting

Results 1 to 12 of 12

Thread: Transform data from vertical to horizontal

  1. #1

    Transform data from vertical to horizontal

    Hello everyone
    I have a code that combines data based on ID and it worked well .. but I need to get the results in another way if possible
    Attachment illustrated the issue better than description
    Thanks advanced for help
    Attached Files Attached Files

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    one way is:

    Sub vbax_58813()
        
        Dim i As Long
        Dim arr, e
    
        arr = Range("A1").CurrentRegion
    
        With CreateObject("Scripting.Dictionary")
            For i = 1 To UBound(arr)
                If Not .Exists(arr(i, 1)) Then
                    .Item(arr(i, 1)) = arr(i, 2)
                Else
                    .Item(arr(i, 1)) = Join(Array(.Item(arr(i, 1)), arr(i, 2)), "~")
                End If
            Next i
            
            i = 1
            For Each e In .Keys
                Cells(i, 7) = e
                Cells(i, 8) = .Item(e)
                i = i + 1
            Next
        End With
        
        Range("G1").CurrentRegion.Columns(2).TextToColumns _
            Destination:=Range("H1"), DataType:=xlDelimited, Other:=True, OtherChar:="~"
    
    End Sub
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3

  4. #4
    Thanks a lot for great help and I am so sorry for not putting the other link. I forgot at all about that as I was in hurry yesterday
    Best Regards

  5. #5
    I am naturally suspicious when someone with quite a few posts says "I forgot"
    Just a quick check for your posts:
    vbaexpress 322
    eileenslounge 644
    mrexcel 650
    excelforum 4443
    and probably a lot in other forums yet.
    So after 6000+ posts, you forgot to mention that one should let the helpers know that it was also posted in another forum!


    Studying to be a politician maybe?

  6. #6
    Mr. jolivanes I really forgot because the time I posted the threads was late and I was in hurry ... And thanks for your reply

  7. #7
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    You can still restore your omission by adding links in this thread to all places where you asked the same question.

  8. #8
    I think you have already done that Mr. snb
    Generally
    http://www.eileenslounge.com/viewtop...628903f521817a

    I don't know if I have to apologize again and again ...for everyone for something I forgot to do

  9. #9
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    when jolivanes pointed your memberships in other forums, snb (and i) thought you opened the same thread in those forums as well. but it seems you have two threads; one here and one in eileen.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  10. #10
    Yes Mr. mancubus
    Just in these two forums.. I usually put links if I posted in two forums but this time I really forgot about it as it was late in my country and I had to finish up my work quickly so I posted in both forums without paying attention to put the links
    Regards

  11. #11
    VBAX Regular
    Joined
    Jul 2013
    Posts
    56
    Location
    I am with jolivanes in post #5.. where i come from.. that's called bul****!

  12. #12
    Thanks Mr. apo

Posting Permissions

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