+ Reply to Thread
Results 1 to 7 of 7

turn vertical list to horizontal list start new row when change in column A, B and E

  1. #1
    Registered User
    Join Date
    07-03-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    10

    turn vertical list to horizontal list start new row when change in column A, B and E

    I have a list of data that I need to turn from vertical to horizontal... I would like to do it via VBA as I have about 40K lines. I need to have it combine all data for each number group with the same type, prod and G/NG code. So all that have the same type, Prod, G/NG and Number need to be in one column with all from the Code column in the row....

    I attached a sample file as well.

    For example

    Starting with

    Number|Type | Code |Prod |G/NG |
    :----:|:----:|:----:|:----:|:----:|
    440 AF 1234 S7 G
    440 AF 7865 S7 G

    440 NY 1235 S7 G
    440 NY 4567 S7 G
    41MM AF 1234 S7 G
    41MM AF 1235 S7 NG

    Should now look like:

    Number|Type | Code1 | Code2| Prod |G/NG |
    :----:|:----:|:----: |:----:|:-----:|:----:|
    440 AF 1234 7865 S7 G
    Attached Files Attached Files
    Last edited by drosew; 12-12-2016 at 03:25 PM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: turn vertical list to horizontal list start new row when change in column A, B and E

    Hi drosew

    What would 41MM look like reconfigured?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    07-03-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: turn vertical list to horizontal list start new row when change in column A, B and E

    41MM would have two rows

    one for the G
    one for the NG

    41MM AF 1234 S7 G
    41MM AF 1234 S7 NG

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,877

    Re: turn vertical list to horizontal list start new row when change in column A, B and E

    Something like this? See attached sample as well.

    Please Login or Register  to view this content.
    Edit:Forgot to remove "Debug.Print" line, you can remove it. It was just used to check logic.
    Attached Files Attached Files
    Last edited by CK76; 12-12-2016 at 05:32 PM. Reason: See Edit:

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,877

    Re: turn vertical list to horizontal list start new row when change in column A, B and E

    Update: While testing code for 40k lines, realized that I forgot to mention following.
    Above code will only work if Code variation per distinct Type, Prod & G/NG is 4 or less. If there could be more, you'll need to modify code, starting at "ReDim resArray..." line.

    Updated code (added maxCode check and made resArray more dynamic, added timer code).
    Please Login or Register  to view this content.
    Note: If there could be duplicate code for distinct combo... you'll need additional check inside first loop.

  6. #6
    Registered User
    Join Date
    07-03-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: turn vertical list to horizontal list start new row when change in column A, B and E

    That is great I have made a helper column that I hope will help, as I don't know the exact number there will be for each different code group. I'm going to attache the new file and see if that might give an better way to go about this. I have done code to add a blank row at each change in a column but not transpose....
    Attached Files Attached Files

  7. #7
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,877

    Re: turn vertical list to horizontal list start new row when change in column A, B and E

    You won't need helper column with logic used in my code sample.

    Here, see modified code for your new column order (I removed the helper column), it will accommodate for varying number of code as well.
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How to turn many rows of horizontal data into one single vertical column
    By ExcelNeverQuit in forum Excel General
    Replies: 4
    Last Post: 08-21-2015, 06:59 PM
  2. Need To Change Horizontal Table to Vertical List
    By jambo2000 in forum Excel General
    Replies: 1
    Last Post: 07-22-2013, 12:42 PM
  3. [SOLVED] Convert Vertical list to Horizontal
    By pmor1503 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-14-2012, 10:15 PM
  4. Switching a Horizontal List to a Vertical List
    By mrvp in forum Excel General
    Replies: 2
    Last Post: 02-28-2012, 07:22 PM
  5. Convert Horizontal data into a 'Cummulative' (one-column) Vertical List
    By Gabino21 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-15-2012, 11:28 PM
  6. Converting vertical list into horizontal list
    By Frenchtom in forum Excel General
    Replies: 2
    Last Post: 09-12-2011, 03:55 PM
  7. Convert from Vertical list to Horizontal
    By ravi_m5_2000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-14-2009, 03:52 AM

Tags for this Thread

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