Re arrange information

yuvalshabt

New Member
Joined
Jan 11, 2017
Messages
24
Office Version
  1. 2021
Platform
  1. Windows
Hi all,
I need some help rearranging information I cant find a solution and I have TONS of this info to sort.

I have the following table that I want to sort in a specific way, but cant find a way to do so:

source:
Size\ modelD18292800D178241D189971
38​
2120292101​
1921369501​
2020611301​
40​
1921369502​
2020611302​
42​
1921369503​
2020611303​
44​
2120292104​
1921369504​
46​
2120292105​
1921369505​
2020611305​
48​
2020611306​
50​
Need:modelsizesku
D18292800
38​
2120292101​
D18292800
44​
2120292104​
D18292800
46​
2120292105​
D178241
38​
1921369501​
D178241
40​
1921369502​
D178241
42​
1921369503​
D178241
44​
1921369504​
D178241
46​
1921369505​
D189971
38​
2020611301​
D189971
40​
2020611302​
D189971
42​
2020611303​
D189971
46​
2020611305​
D189971
48​
2020611306​
 

Attachments

  • Screenshot_1.png
    Screenshot_1.png
    22.3 KB · Views: 12

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
One click in Power Query:

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    unPiv = Table.UnpivotOtherColumns(Source, {"Size\ model"}, "Model", "Value")
in
    unPiv

Book1
ABCDEFGHI
1Size\ modelD18292800D178241D189971Size\ modelModelValue
23821202921011921369501202061130138D182928002120292101
3401921369502202061130238D1782411921369501
4421921369503202061130338D1899712020611301
5442120292104192136950440D1782411921369502
64621202921051921369505202061130540D1899712020611302
748202061130642D1782411921369503
85042D1899712020611303
944D182928002120292104
1044D1782411921369504
1146D182928002120292105
1246D1782411921369505
1346D1899712020611305
1448D1899712020611306
Sheet1
 
Upvote 0
I honestly dont know whats power query....
Thank you, Ill try to figure it out!!
 
Upvote 0
With a formula
Fluff.xlsm
ABCD
1Size\ modelD18292800D178241D189971
238212029210119213695012020611301
34019213695022020611302
44219213695032020611303
54421202921041921369504
646212029210519213695052020611305
7482020611306
850
9
10
11
12D18292800382120292101
13D18292800442120292104
14D18292800462120292105
15D178241381921369501
16D178241401921369502
17D178241421921369503
18D178241441921369504
19D178241461921369505
20D189971382020611301
21D189971402020611302
22D189971422020611303
23D189971462020611305
24D189971482020611306
25
Data
Cell Formulas
RangeFormula
A12:C24A12=LET(d,B2:D8,r,ROWS(d),c,COLUMNS(d),s,SEQUENCE(r*c,,0),x,INDEX(B1:D1,INT(s/r)+1),y,INDEX(A2:A8,MOD(s,r)+1),z,INDEX(d,MOD(s,r)+1,INT(s/r)+1),aa,CHOOSE({1,2,3},x,y,z),FILTER(aa,INDEX(aa,,3)<>0))
Dynamic array formulas.
 
Upvote 0
With a formula
Fluff.xlsm
ABCD
1Size\ modelD18292800D178241D189971
238212029210119213695012020611301
34019213695022020611302
44219213695032020611303
54421202921041921369504
646212029210519213695052020611305
7482020611306
850
9
10
11
12D18292800382120292101
13D18292800442120292104
14D18292800462120292105
15D178241381921369501
16D178241401921369502
17D178241421921369503
18D178241441921369504
19D178241461921369505
20D189971382020611301
21D189971402020611302
22D189971422020611303
23D189971462020611305
24D189971482020611306
25
Data
Cell Formulas
RangeFormula
A12:C24A12=LET(d,B2:D8,r,ROWS(d),c,COLUMNS(d),s,SEQUENCE(r*c,,0),x,INDEX(B1:D1,INT(s/r)+1),y,INDEX(A2:A8,MOD(s,r)+1),z,INDEX(d,MOD(s,r)+1,INT(s/r)+1),aa,CHOOSE({1,2,3},x,y,z),FILTER(aa,INDEX(aa,,3)<>0))
Dynamic array formulas.
Wow, amazing! Thank you very much!!!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
VBA approach. Change the sheet names (in red) to suit your needs.
Rich (BB code):
Sub RearrangeData()
    Application.ScreenUpdating = False
    Dim lRow As Long, lCol As Long, arr() As Variant, arr2() As Variant, v As Variant, r As Long, c As Long, x As Long
    Dim srcWS As Worksheet, desWS As Worksheet
    Set srcWS = Sheets("Sheet1")
    Set desWS = Sheets("Sheet2")
    desWS.Range("A1").Resize(, 3).Value = Array("Model", "Size", "SKU")
    lRow = srcWS.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    lCol = srcWS.Cells(2, srcWS.Columns.Count).End(xlToLeft).Column
    v = srcWS.Range("A2", srcWS.Range("A" & Rows.Count).End(xlUp)).Resize(, lCol).Value
    For c = LBound(v, 2) + 1 To UBound(v, 2)
        For r = LBound(v) + 1 To UBound(v)
            If v(r, c) <> "" Then
                x = x + 1
                ReDim Preserve arr(1 To x)
                ReDim Preserve arr2(1 To x)
                arr(x) = v(r, 1)
                arr2(x) = v(r, c)
            End If
        Next r
        With desWS
            .Cells(.Rows.Count, "A").End(xlUp).Offset(1).Resize(x) = v(1, c)
            .Cells(.Rows.Count, "B").End(xlUp).Offset(1).Resize(x) = Application.Transpose(arr)
            .Cells(.Rows.Count, "C").End(xlUp).Offset(1).Resize(x) = Application.Transpose(arr2)
        End With
        x = 0
    Next c
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
FYI

Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

- Follow this link to learn how to install Power Query in Excel 2010 / 2013.

- Follow this link for an introduction to Power Query functionality.

- Follow this link for a video which demonstrates how to use Power Query code provided.
 
Upvote 0

Forum statistics

Threads
1,221,605
Messages
6,160,768
Members
451,670
Latest member
Peaches000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top