+ Reply to Thread
Results 1 to 10 of 10

Separate data in one row into several rows

Hybrid View

  1. #1
    Registered User
    Join Date
    10-05-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    3

    Separate data in one row into several rows

    I am trying to work out how or if this is possible!

    I have data which appears on one line that I need to separate into single lines. The information is being downloaded from a form where a manger can add multiple members of staff, which when downloaded to excel all appears as continual data on one line. A new row appears for each manager.

    Below is a sample of the info for one person, these headers are repeated for as many people on the form. So some rows may have 10 employees other rows may only have 2. (make sense?)

    Last Name First Name Middle Initial Email Shipping Address 1 Shipping Address 2 City State (Province) Zipcode Country Primary Phone

    Question is can these be separated so they all appear stacked rather than in a row?

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    re: Separate data in one row into several rows

    "appear stacked rather than in a row?" NEEDS CLARIFICATION

    HAD You given a sample copy it would have been helpful. anyhow see attached file sheet 1
    I expect your data is like this in the upper potion of sheet
    the result you need is something like this in the lower portion. sometimes example is better than thousand words.
    Attached Files Attached Files
    I am not an expert. better solutions may be available
    [email protected]

  3. #3
    Registered User
    Join Date
    10-05-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Separate data in one row into several rows

    Thank you for a quick reply.

    Sorry I wasn't clearer, first time posting and now I reread it I did need more clarification.

    I am re attaching the file with the current format and what I need it to eventually to be.

    Many Thanks

    Damian

    DAIMIAN.xlsx

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Separate data in one row into several rows

    Give this a try

    DAIMIAN_v2.xlsm

    Edit: Results are added to sheet2
    Last edited by mike7952; 10-08-2012 at 04:42 PM.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  5. #5
    Registered User
    Join Date
    10-05-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Separate data in one row into several rows

    Thank you Thank you so much this is great, exactly what I needed.

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

    Re: Separate data in one row into several rows

    Try
    Option Explicit
    
    Sub test()
        Dim a, b, i As Long, ii As Long, n As Long
        a = Sheets("sheet1").Range("a1").CurrentRegion
        ReDim b(1 To UBound(a, 2), 1 To UBound(a, 1))
        For i = 1 To UBound(a, 2)
            b(i, 1) = a(1, i)
        Next
        n = 1
        For i = 2 To UBound(a, 1)
            If a(i, 1) <> "Last Name" Then
                n = n + 1
                b(1, n) = a(i, 1)
                For ii = 2 To UBound(a, 2)
                    b(ii, n) = a(i, ii)
                Next
            End If
        Next
        With Sheets("sheet2").Cells(1).Resize(UBound(b, 1), n)
            .CurrentRegion.ClearContents
            .Value = b
            .Parent.Activate
        End With
    End Sub
    Attached Files Attached Files

  7. #7
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Separate data in one row into several rows

    @Jindon,

    I think the workbook the OP uploaded is a little confusing. Look down on row 31. If my code worked then I guessed right about everything above row 31 needs to be deleted an that is what the OP data looks like. So all the data above row 31 is not really there in actual worksheet.


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

    Re: Separate data in one row into several rows

    My solution is only based on the file uploaded by OP, nothing else.

  9. #9
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Separate data in one row into several rows

    If you look at post #2 where Venkat uploaded the wb and the OP modified his upload below starting in row 31
    Last edited by mike7952; 10-08-2012 at 07:40 PM.

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

    Re: Separate data in one row into several rows

    Ahh, I think I missed that one
    Sub test()
        Dim i As Long, ii As Long, n As Long
        With Sheets("sheet1").Range("a1").CurrentRegion
            .Rows(1).Resize(, 12).Copy Sheets("sheet2").Range("a1")
            n = 1
            For i = 2 To .Rows.Count
                For ii = 1 To .Columns.Count Step 12
                    n = n + 1
                    .Cells(i, ii).Resize(, 12).Copy Sheets("sheet2").Cells(n, 1)
            Next ii, i
        End With
    End Sub

+ 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