Search code examples
excelexcel-formula

convert column range into single column one column below the next column


I have a data certain Rows and Columns. I need to convert all the columns one after the below.

Pic1

=LET(a,A2:A11,cn,COUNTA(B2:D2),_a,TEXTSPLIT(REPT(TEXTJOIN(",",,a)&"$",cn),,{",","$"},1),_a)

I tried multiple ways to get other columns (ID, Region, WC) one after below as shown in image, but I couldn't succeed.

Any help really appreciated.

Thank you.


Solution

  • In this formula
    cols is the count of the columns with unique column names.
    sta contains the columns from the second till the end of the range stacked in one column
    fir and par repeat the first column as many times as cols value.

    =LET(a,A2:D5,
    cols,COLUMNS(a)-1,
    sta,TOCOL(DROP(a,,1),0,TRUE),
    fir,REPT(TEXTJOIN("|",FALSE,TAKE(a,,1))&"|",cols),
    par,DROP(TOCOL(TEXTSPLIT(fir,"|")),-1),
    HSTACK(par,sta))