+ Reply to Thread
Results 1 to 9 of 9

Transpose variable row data into columns

  1. #1
    Registered User
    Join Date
    07-15-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Transpose variable row data into columns

    I am new to the forum but have found some helpful stuff here so far.

    I have a project that I am working on and have over 68 thousand records that have all the data in one column that I need to get into multiple columns. The good thing is each record is broken up by a blank row but some records could have 1 line or 6 lines that I need to move to columns. If there is only 1 row then it goes to column 6, 2 rows then they go to column 5 and 6, 3 lines column 4, 5 and 6...etc.

    Example:
    data
    data
    data
    <blank row>
    data
    <blank row>
    data
    data
    <blank row>
    data
    data
    data

    Desired result:
    Column 1 Column 2 Column 3
    this didnt come out right. if i need to i can poste the spreadsheet

    Thanks,
    Russell

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Transpose variable row data into columns

    Russell - please post a workbook illustrating data and desired results.

    EDIT: if I have understood correctly, perhaps this. It assumes data in column A of sheet 1 and puts results on sheet 2
    Please Login or Register  to view this content.
    Last edited by StephenR; 07-18-2011 at 11:33 AM.

  3. #3
    Registered User
    Join Date
    07-15-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Transpose variable row data into columns

    Unfortunately I am not able to upload information from my pc at work. See if this is a better description.
    current
    data1
    data2
    data3

    data21
    data22

    data31

    data41
    data42
    data43
    data44
    data45

    data51
    data52
    data53

    data61
    data62
    data63

    wanted results
    Column1 Column2 Column3 Column4 Column5 Column6 Column7
    data1 data2 data3
    data21 data22
    data31
    data41 data42 data43 data44 data45

    This is still not formatted correctly but the idea is to have the data go into its respective column.

    So, yes there is data in column A and putting it on sheet 2 is fine if that is easier. So I want it transposed until a space is found, then get the next row and transpose until there is no more data. Range is to 68000.

    Thanks
    Last edited by rjackson444; 07-18-2011 at 12:59 PM.

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Transpose variable row data into columns

    So, have you tried the code?

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Transpose variable row data into columns

    The problem with SPECIAL CELLS is that is can only work with less than 8000 distinct "areas" at once. Your description of the issue makes me think the areas method will fail in a too-simple application across the whole dataset at once.

    This version of the technique breaks your data down into groups of 10000 rows or so, to be safe, and processes them in groups. The result should be the same, but this is more defensive:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Transpose variable row data into columns

    Quote Originally Posted by StephenR View Post
    So, have you tried the code?
    Heh, have you? I did, it failed just as expected on a dataset that large. Special Cells can't handle that many areas, so it just flops back to one big area and fails. Special Cells is one of my faves, but it's a tempermental critter. I'm glad the OP told us his data was that large..

  7. #7
    Registered User
    Join Date
    07-15-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Transpose variable row data into columns

    Quote Originally Posted by StephenR View Post
    So, have you tried the code?

    I did but was getting Application-defined or object-defined error on line

    Sheet2.Cells(n, 7 - r.Count).PasteSpecial Transpose:=True

    Thanks,
    Russell

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Transpose variable row data into columns

    Russell, use the more defensive approach from post #5.

  9. #9
    Registered User
    Join Date
    07-15-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Transpose variable row data into columns

    It worked great JB, thanks much for the quick help.

+ 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