+ Reply to Thread
Results 1 to 11 of 11

Multiple transpose function from rows into columns

  1. #1
    Registered User
    Join Date
    09-26-2011
    Location
    Leeds, England
    MS-Off Ver
    Excel 2010
    Posts
    3

    Multiple transpose function from rows into columns

    Hi there,

    I am looking for a method to be able to do multiple transpose function, rather than doing it seperately.

    I have approximately 5000 rows of data 2 columns, that needs to be converted into 6 columns of data so hence 1000 rows. So I want to know of method of doing it all in one go rather than 1000 seperate times, as it is very time consuming.

    after being converted, some rows may have only 4 or upto 6 columns of data.

    Here is it looks like now:

    1 - LA1
    1 - LA2
    1 - LA3
    1 - LA4
    1 - LA5
    2 - LB1
    2 - LB2
    2 - LB3
    2 - LB4
    2 - LB5
    3 - LC1
    3 - LC2
    3 - LC4
    3 - LC3


    I want to change it into this format:

    1 LA1 LA2 LA3 LA4 LA5
    2 LB1 LB2 LB3 LB4 LB5
    3 LC1 LC2 LC3 LC4 LC5


    I thank anyone in advanced that can help with this problem alot!

    Regards

    Fletchy888

  2. #2
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Multiple transpose function from rows into columns

    fletchy888,

    Welcome to the Excel Forum.

    It is hard to tell where your data begins (rows and columns).

    To get the most precise answer, it is best to upload/attach a sample workbook (sensitive data scrubbed/removed/changed) that contains an example of your raw data on one worksheet, and on another worksheet your desired results.

    The structure and data types of the sample workbook must exactly duplicate the real workbook. Include a clear and explicit explanation of your requirements.

    To attach your workbook, click on the New Post button, then scroll down and click on the Go Advanced button, then scroll down and click on the Manage Attachments button.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  3. #3
    Registered User
    Join Date
    09-26-2011
    Location
    Leeds, England
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Multiple transpose function from rows into columns

    I noticed that I said that I am using excel 2010, it is the 2003 version that I am using, my apologies.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Multiple transpose function from rows into columns

    Here is a method using Formulas only.

    Assuming your data is in Sheet1, column A:B, starting at A2.

    First in a new column, say C2, enter:

    =A2&"_"&COUNTIF(A$2:A2,A2)

    copied down.

    Then in Sheet2, A2

    =COUNTIF(Sheet1!A:A,B2)

    copied down

    In column B list your unique numbers and then in C2:

    =IF(COLUMNS(Sheet1!$F$1:F$1)>$A2,"",INDEX(Sheet1!$B:$B,MATCH($B2&"_"&COLUMNS(Sheet1!$F$1:F$1),Sheet1!$C:$C,0)))

    copied down and across.

    Then copy everything in Sheet2, and Edit|Paste Special >> Values over itself.

    You can then delete column A in Sheet2 and have your data.
    Attached Files Attached Files
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  5. #5
    Registered User
    Join Date
    09-26-2011
    Location
    Leeds, England
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Multiple transpose function from rows into columns

    A sample of my file is in the attachment
    Attached Files Attached Files

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Multiple transpose function from rows into columns

    Try the solution I offered above.

  7. #7
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Multiple transpose function from rows into columns

    fletchy888,

    Thanks for the workbook.

    I assume that your raw data is always in worksheet Sheet1. The macro will create a new worksheet Results.


    Detach/open workboo ReorgData arrays w1 Aary Bary wR Oary - fletchy888 - EF793907 - SDG16.xls and run macro ReorgData.



    If you want to use the macro on another workbook:


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

    1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
    2. Open your workbook
    3. Press the keys ALT + F11 to open the Visual Basic Editor
    4. Press the keys ALT + I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
    7. Press the keys ALT + Q to exit the Editor, and return to Excel
    8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


    Please Login or Register  to view this content.

    Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm

    Then run the ReorgData macro.

  8. #8
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Multiple transpose function from rows into columns

    fletchy888,

    I assume that your raw data is always in worksheet Sheet1. The macro will create a new worksheet Results.

    Detach/open workbook ReorgData arrays w1 Aary Bary wR Oary ReDimPreserve - fletchy888 - EF793907 - SDG16.xls and run macro ReorgDataV2.


    If you want to use the macro on another workbook:


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

    1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
    2. Open your workbook
    3. Press the keys ALT + F11 to open the Visual Basic Editor
    4. Press the keys ALT + I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
    7. Press the keys ALT + Q to exit the Editor, and return to Excel
    8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


    Please Login or Register  to view this content.

    Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm


    Then run the ReorgDataV2 macro.

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Multiple transpose function from rows into columns

    Is there any difference?

  10. #10
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Multiple transpose function from rows into columns

    NBVC,

    Is there any difference?
    Yes, I am now using ReDim Preserve to adjust how many columns are used in the output array, instead of the Countif formula in worksheet Sheet1.

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Multiple transpose function from rows into columns

    You should mention that so the OP is not confused and uses the "correct" one.

+ 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