Closed Thread
Results 1 to 23 of 23

Transpose large amount of Rows by multiple Columns

  1. #1
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Transpose large amount of Rows by multiple Columns

    Hi Forum,
    I have a worksheet of data comprised of 3 fields of Values plus a 4th Column containing the Figure Headings and a 5th with the actual Figures for those fields.
    I've attached a sample worksheet to show the before and after.
    There are about a full worksheet (1,000,000+) of rows to transpose.
    I have a couple of examples created by jindon which are great, but now I need to handle more data as I am getting errors when running the code.

    I've attached the 2 Macros to show where I'm at:

    The first errors due to the number of rows to process and I am getting an error not recognising the source data for the second.

    Please Login or Register  to view this content.
    Second solution:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Remember you are unique, like everyone else

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Transpose large amount of Rows by multiple Columns

    data comprised of 3 fields of Values plus a 4th Column containing the Figure Headings and a 5th with the actual Figures for those fields.
    This is based on sample supplied...
    If not working then try and upload a sample with a much larger dataset...
    Please Login or Register  to view this content.
    Last edited by Sintek; 02-15-2024 at 01:45 AM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: Transpose large amount of Rows by multiple Columns

    Thanks sintek,
    I tried it but I get a 'Subscript out of Range' error at this line:

    Temp(x, xx) = Data(i, 5)

    Also, would you be able to add comments to show your logic?
    Thanks Peter

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,062

    Re: Transpose large amount of Rows by multiple Columns

    That's exactly what a pivot table would produce - is there a reason for not using one? Or PQ would do the same job but produce a table.
    Everyone who confuses correlation and causation ends up dead.

  5. #5
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Transpose large amount of Rows by multiple Columns

    I tried it but I get a 'Subscript out of Range' error at this line:
    Works for your sample file...Not so?
    Like I said, if not working for actual add a sample file representing your actual data...
    Attached Files Attached Files
    Last edited by Sintek; 02-14-2024 at 05:20 AM.

  6. #6
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: Transpose large amount of Rows by multiple Columns

    Hi rorya,
    Yes, this is to replace a Pivot Table to improve the integrity of a report.
    Having hardcoded results avoids any mistakes if someone inadvertently makes changes to the pivot.

  7. #7
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: Transpose large amount of Rows by multiple Columns

    I didn't want to post a full worksheet of data due to the size.
    Why wouldn't your code work on my sample but work on a larger dataset?

  8. #8
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Transpose large amount of Rows by multiple Columns

    Why wouldn't your code work on my sample
    It does work on your sample...have you tested the file I attached in post 5

  9. #9
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: Transpose large amount of Rows by multiple Columns

    Yes, and as I stated, I get the error.

    I tried it but I get a 'Subscript out of Range' error at this line:

    Temp(x, xx) = Data(i, 5)

  10. #10
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Transpose large amount of Rows by multiple Columns

    This is what i get when i press the button...

    Untitled.png

    Cannot see why you would get an error if we are both pushing the same button in the same file...
    Last edited by Sintek; 02-14-2024 at 05:48 AM.

  11. #11
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,906

    Re: Transpose large amount of Rows by multiple Columns

    Please Login or Register  to view this content.
    Power Query
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,062

    Re: Transpose large amount of Rows by multiple Columns

    Quote Originally Posted by noboffinme View Post
    Hi rorya,
    Yes, this is to replace a Pivot Table to improve the integrity of a report.
    Having hardcoded results avoids any mistakes if someone inadvertently makes changes to the pivot.
    You could just make a pivot, then copy and paste values.

  13. #13
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: Transpose large amount of Rows by multiple Columns

    Thanks, however the report also uses a function using some of the fields.
    If anyone changes the pivot, what's copied will be incorrect.

  14. #14
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: Transpose large amount of Rows by multiple Columns

    Thanks alansidman, I'll take a look.

  15. #15
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: Transpose large amount of Rows by multiple Columns

    Hi sintek,
    I tried it using the button and then using the VB editor, it works great!
    Thank you.
    Would you be able to add comments to explain your logic?
    Thank you
    Peter

  16. #16
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Transpose large amount of Rows by multiple Columns

    Glad we got it sorted...
    Would you be able to add comments to explain your logic?
    '! Comments Added Above...

  17. #17
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: Transpose large amount of Rows by multiple Columns

    Hi sintek, I wonder if you help me follow the purpose of the below line?

    Please Login or Register  to view this content.
    Thanks

  18. #18
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Transpose large amount of Rows by multiple Columns

    I have no desire to learn power query so cannot assist...alan will explain this in more detail...
    Tx for rep by the way...Glad I could assist...

  19. #19
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: Transpose large amount of Rows by multiple Columns

    Hi sintek,
    This line is from your code, it's not from Power Query.
    I wanted to know what effect the cn 3,3,1 has?
    Thanks

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

    Re: Transpose large amount of Rows by multiple Columns

    That's my code
    https://www.excelforum.com/excel-pro...nce-field.html

    This is a duplicate thread, so against the forum rule, and you said
    I follow the 2nd one
    Means you understand SQL... what a...

  21. #21
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: Transpose large amount of Rows by multiple Columns

    Since you only have time for experts why don't you just go away ...

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

    Re: Transpose large amount of Rows by multiple Columns

    Step debug is the one of the best tools for both BEGINERS/experts to understand the code.

    Adding comments in each line of code doesn't help, especially for BEGINNERs most of the case.

  23. #23
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,824

    Re: Transpose large amount of Rows by multiple Columns

    Administrative Note:

    Unfortunately, this is a duplicate thread, and you are allowed only ONE thread per issue here.

    Please see Forum Rule #2 about thread duplication.

    I am closing this thread, but you may continue here in the original thread: https://www.excelforum.com/excel-pro...nce-field.html

    Thread closed.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Transpose large amount of data
    By vixell23 in forum Excel General
    Replies: 2
    Last Post: 11-14-2017, 07:42 PM
  2. Replies: 4
    Last Post: 02-05-2016, 09:50 AM
  3. Replies: 1
    Last Post: 01-24-2014, 06:20 PM
  4. [SOLVED] Transpose rows to columns in large data set
    By Larne-O in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 04-03-2013, 04:04 AM
  5. [SOLVED] Transpose Large Amount of Data
    By engineerlady in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-09-2013, 12:56 PM
  6. [SOLVED] Transpose rows to columns: variable amount of colums and corresponding values
    By Browser in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-10-2012, 10:40 AM
  7. Replies: 7
    Last Post: 11-11-2005, 12:30 PM

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