+ Reply to Thread
Results 1 to 7 of 7

Transpose rows of data to column, with 1st cell in row repeated

  1. #1
    Registered User
    Join Date
    10-12-2012
    Location
    Southampton, England
    MS-Off Ver
    365
    Posts
    26

    Transpose rows of data to column, with 1st cell in row repeated

    Hi,

    Difficult one to explain so I have mocked up an example attached. I found a formula online that works but only for a maximum of 3 cells in the row. Each row can contain more or less than 3 cells of data, please could you help modify this formula or suggest a new formula to achieve how I would like the final columns of data to look in the example.

    Appreciate your help, been scratching my head for ages!

    Thanks,
    Adam.
    Attached Files Attached Files

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Transpose rows of data to column, with 1st cell in row repeated

    Hi,

    So the entries in the range B2:K5 are unique, just as in your example?

    If so, in Q2:

    =INDEX(A$2:A$5,MIN(IF(B$2:K$5=R2,SEQUENCE(ROWS(B$2:K$5)))))

    In R2:

    =FILTERXML("<a><b>"&TEXTJOIN("</b><b>",1,B$2:K$5)&"</b></a>","//b")

    The first needs to be copied down, the second will automatically spill down.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,973

    Re: Transpose rows of data to column, with 1st cell in row repeated

    With Get and Transform found on the Data Tab
    Highlihgt your table
    Click on From Table or Range
    Highliht the Stock Number Column
    Click on Unpivot --> Unpivot other columns
    Highlight Attribute Column --> Click on Delete column
    Close and Load

    Resulting Mcode

    Please Login or Register  to view this content.
    Result

    Excel 2016 (Windows) 32 bit
    A
    B
    1
    Stock Number Value
    2
    SKU01 Red
    3
    SKU01 Blue
    4
    SKU01 Green
    5
    SKU01 Black
    6
    SKU01 Purple
    7
    SKU01 Brown
    8
    SKU01 Orange
    9
    SKU01 Yellow
    10
    SKU01 Navy
    11
    SKU01 Pink
    12
    SKU02 Small
    13
    SKU02 Medium
    14
    SKU02 Large
    15
    SKU02 X-Small
    16
    SKU02 X-Large
    17
    SKU03
    1
    18
    SKU03
    2
    19
    SKU03
    3
    20
    SKU03
    4
    21
    SKU03
    5
    22
    SKU03
    6
    23
    SKU03
    7
    24
    SKU03
    8
    25
    SKU03
    9
    26
    SKU03
    10
    27
    SKU04 Excel
    28
    SKU04 Word
    29
    SKU04 Powerpoint
    30
    SKU04 Outlook
    Sheet: Sheet2
    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

  4. #4
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,109

    Re: Transpose rows of data to column, with 1st cell in row repeated

    Hi,

    With a helper in columns M-N


    N2 =SUM(--(ISTEXT((IF((M2=$A$2:$A$5),$B$2:$K$5)))))+COUNT(1/(IF((M2=$A$2:$A$5),$B$2:$K$5)))

    O2 =A2
    O3 =IFERROR(IF(VLOOKUP(O2,$M$2:$N$19,2,0)<=COUNTIF($O$1:O2,O2),INDEX($M$2:$M$19,MATCH(O2,$M$2:$M$19)+1),O2),"")

    P2 =IFERROR(INDEX($B$2:$K$5,MATCH(O2,$A$2:$A$5,0),SMALL(IF((O2=$A$2:$A$5)*($B$2:$K$5<>""),COLUMN($B$2:$K$5)),IF(O2="",VLOOKUP(O2,$M$2:$N$5,2,0),VLOOKUP(O2,$M$2:$N$5,2,0)-COUNTIF(O3:$O$83,O2)))-1),"")
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-12-2012
    Location
    Southampton, England
    MS-Off Ver
    365
    Posts
    26

    Re: Transpose rows of data to column, with 1st cell in row repeated

    Thank you all very much for a looking at this so quickly.

    I went with the below, for my limited understanding of these formula's I was able to get this one to work for a much larger volume of data.

    Quote Originally Posted by belinda200 View Post
    Hi,

    With a helper in columns M-N


    N2 =SUM(--(ISTEXT((IF((M2=$A$2:$A$5),$B$2:$K$5)))))+COUNT(1/(IF((M2=$A$2:$A$5),$B$2:$K$5)))

    O2 =A2
    O3 =IFERROR(IF(VLOOKUP(O2,$M$2:$N$19,2,0)<=COUNTIF($O$1:O2,O2),INDEX($M$2:$M$19,MATCH(O2,$M$2:$M$19)+1),O2),"")

    P2 =IFERROR(INDEX($B$2:$K$5,MATCH(O2,$A$2:$A$5,0),SMALL(IF((O2=$A$2:$A$5)*($B$2:$K$5<>""),COLUMN($B$2:$K$5)),IF(O2="",VLOOKUP(O2,$M$2:$N$5,2,0),VLOOKUP(O2,$M$2:$N$5,2,0)-COUNTIF(O3:$O$83,O2)))-1),"")
    Thank you all again.

    Regards,
    Adam.

  6. #6
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,109

    Re: Transpose rows of data to column, with 1st cell in row repeated

    You're welcome ads111ads

  7. #7
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,109

    Re: Transpose rows of data to column, with 1st cell in row repeated

    Quote Originally Posted by alansidman View Post
    With Get and Transform found on the Data Tab
    Highlihgt your table
    Click on From Table or Range
    Highliht the Stock Number Column
    Click on Unpivot --> Unpivot other columns
    Hi Alan,
    can you please explain where is the unpivot? Is it in the Powerquery editor or a stage before the page opens?

    Thanks.

+ 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. Transpose rows to column and insert new rows to fill in data
    By Apple Ling in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-24-2019, 04:02 AM
  2. Replies: 3
    Last Post: 11-20-2018, 09:27 PM
  3. [SOLVED] Transpose data from rows to column
    By Barieq in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-17-2016, 02:08 AM
  4. Replies: 2
    Last Post: 01-29-2014, 09:50 AM
  5. Insert rows, transpose data from column in to rows, in steps
    By mchevalier in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2012, 08:14 PM
  6. Replies: 6
    Last Post: 07-05-2011, 07:18 PM
  7. Transpose Data from a column to several rows
    By stansdl in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-30-2006, 05:45 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