+ Reply to Thread
Results 1 to 5 of 5

split & transpose columns to rows?

Hybrid View

  1. #1
    Registered User
    Join Date
    05-17-2012
    Location
    Liverpool, England
    MS-Off Ver
    Excel 2007
    Posts
    2

    split & transpose columns to rows?

    HI,

    Looking for some help please, I've been playing with formula to do this and I know I can copy, paste special, transpose. But wanted a quicker way to automate this process.

    I've attached a simple worksheet, similar to that which I'm working on (the real thing has 4000 rows and apprx 20 columns!).

    I need to produce the data in column B against each individual named in column A, I've used the simple IF function in column C to be able to produce a 'false' so I can establish where each range begins and ends as each range is different.

    Thanks
    T
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: split & transpose columns to rows?

    Hello there,

    What did you want your results to look like?

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: split & transpose columns to rows?

    Hard to see what you are after all you have in the attached workbook is a short list of 1st names, weeksays and a true/false formua?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    05-17-2012
    Location
    Liverpool, England
    MS-Off Ver
    Excel 2007
    Posts
    2

    Smile Re: split & transpose columns to rows?

    Thanks for replying - Sorry, data I'm working with is person identifiable so can't attach it.

    Basically I've got approx 4000 rows of dates of service contacts with patients and each
    date has an identifier next to it - I've got approx 500 individuals in the data. What I
    want in the results is a row of dates per patient so that I'll only have approx 500
    unique rows with identifiers in column A and dates starting in column B and stretching
    across columns as far as they need to for each individual.

    Which is why I mocked up this really simole version of my data to share with you .....
    Thought it might help!

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: split & transpose columns to rows?

    try
    Sub test()
        Dim a, b(), i As Long, n As Long
        Dim AL As Object
        Set AL = CreateObject("System.Collections.ArrayList")
        a = Sheets("info").Range("a1").CurrentRegion.Value
        For i = 1 To UBound(a, 1)
            If Not AL.Contains(a(i, 2)) Then AL.Add a(i, 2)
        Next
        ReDim b(1 To UBound(a, 1), 1 To AL.Count)
        n = n + 1
        For i = 0 To AL.Count - 1
            b(n, i + 1) = AL(i)
        Next
        With CreateObject("Scripting.Dictionary")
            .CompareMode = 1
            For i = 1 To UBound(a, 1)
                If Not .exists(a(i, 1)) Then
                    n = n + 1
                    .Item(a(i, 1)) = n
                End If
                b(.Item(a(i, 1)), AL.IndexOf(a(i, 2), 0) + 1) = a(i, 1)
            Next
        End With
        With Sheets("result").Cells(1).Resize(n, AL.Count)
            .CurrentRegion.Clear
            .Value = b
        End With
        Set AL = Nothing
    End Sub
    Attached Files Attached Files
    Last edited by jindon; 05-18-2012 at 03:29 PM.

+ 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