Tranpose ROW Header (YearWeek) and Qty to COL Lists

Spirax

New Member
Joined
Apr 15, 2018
Messages
2
Current Report
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Cust Code
[/TD]
[TD]Plant code
[/TD]
[TD]Vendor code
[/TD]
[TD]201822
[/TD]
[TD]201823
[/TD]
[TD]201824
[/TD]
[TD]201825
[/TD]
[TD]201826
[/TD]
[/TR]
[TR]
[TD]C1
[/TD]
[TD]P1
[/TD]
[TD]V1
[/TD]
[TD]1
[/TD]
[TD][/TD]
[TD]4
[/TD]
[TD]1
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]C2
[/TD]
[TD]P2
[/TD]
[TD]V2
[/TD]
[TD][/TD]
[TD]2
[/TD]
[TD][/TD]
[TD][/TD]
[TD]3
[/TD]
[/TR]
</tbody>[/TABLE]


New Report - easily to do excel formular later
Cust code-Plant code-Vendor code becoming new header, empty cell are ignored

[TABLE="class: grid, width: 150"]
<tbody>[TR]
[TD]C1
[/TD]
[TD]P1
[/TD]
[TD]V1
[/TD]
[/TR]
[TR]
[TD]201822
[/TD]
[TD]1
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]201824
[/TD]
[TD]4
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]201825
[/TD]
[TD]1
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]C2
[/TD]
[TD]P2
[/TD]
[TD]V2
[/TD]
[/TR]
[TR]
[TD]201823
[/TD]
[TD]2
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]201826
[/TD]
[TD]3
[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Thank to advised vba method :)
 

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".
Try this for results on sheet2 starting "A1".
Code:
[COLOR="Navy"]Sub[/COLOR] MG24May11
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, Ray [COLOR="Navy"]As[/COLOR] Variant, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
Ray = ActiveSheet.Cells(1).CurrentRegion
ReDim nray(1 To UBound(Ray, 1) * UBound(Ray, 2), 1 To 3)
[COLOR="Navy"]For[/COLOR] n = 2 To UBound(Ray, 1)
    [COLOR="Navy"]If[/COLOR] Application.CountA(Cells(n, 4).Resize(, UBound(Ray, 2) - 4)) > 0 [COLOR="Navy"]Then[/COLOR]
        c = c + 1
        nray(c, 1) = Ray(n, 1)
        nray(c, 2) = Ray(n, 2)
        nray(c, 3) = Ray(n, 3)
      
            [COLOR="Navy"]For[/COLOR] Ac = 4 To UBound(Ray, 2)
                [COLOR="Navy"]If[/COLOR] Not IsEmpty(Ray(n, Ac)) [COLOR="Navy"]Then[/COLOR]
                    c = c + 1
                    nray(c, 1) = Ray(1, Ac)
                    nray(c, 2) = Ray(n, Ac)
                [COLOR="Navy"]End[/COLOR] If
            [COLOR="Navy"]Next[/COLOR] Ac
    [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]With[/COLOR] Sheets("Sheet2").Range("A1").Resize(c, 3)
    .value = nray
    .Borders.Weight = 2
    .Columns.AutoFit
 [COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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