excelvbaexcel-formula

Tranpose irregular rows into columns and shift one row down


I have an Excel file with this data format.

enter image description here

Now I want to transform those data into column, like this.

enter image description here

How should I do that with Excel Formula or VBA scripts?

I have tried using Transpose paste but it overwrites the rows underneath.


Solution

  • Using Excel Formulas it can be accomplished like as below:

    enter image description here


    • Formula used in cell A6

    =HSTACK(TOCOL(IFS(B2:E4<>"",A2:A4),3),TOCOL(B2:E4,1))
    

    Also I had prefer using POWER QUERY. To achieve this using the said procedure, follow this simple steps using POWER QUERY window UI:

    enter image description here





    let
        Source = Excel.CurrentWorkbook(){[Name="Table_1"]}[Content],
        #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"SKU"}, "Attribute", "Value"),
        #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Other Columns",{"Attribute"}),
        #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Value", "Images"}})
    in
        #"Renamed Columns"
    

    enter image description here



    enter image description here