VBA - Modify table data in a transpose-y way

Zenru

New Member
Joined
Oct 19, 2017
Messages
29
Hi, I have a horrible table with information which was left to me. A bit of the legacy the previous dude left. The table goes like this:

OrderMaterialSizeA1SizeA2SizeB1SizeB2SizeC1SizeC2Doz1Doz2
1234MAT13031AAAGMGN2463
4321MAT24044XL4XMNMO524636
5443MAT3503XLQQ2516

<tbody>
</tbody>

It is a table that has some orders of some materials and their sizes. Each order and material can have up to 20 sizes. So, there really should be SizeA1 to SizeA20, SizeB1 to Size B20 and SizeC1 to SizeC20 and Doz1 to Doz20.

In reality SizeA1 to 20 are the main sizes and SizeB and SizeC are just different versions for different processes. Just when you see different size codes for shoes in different countries but they all mean the same.

The way this data is ordered makes it to hard to read and work with, so I need a way to modify it so it becomes like this:

OrderMaterialSizeDoz
1234MAT13024
1234MAT13163
1234MAT1A24
1234MAT1AA63
1234MAT1GM24
1234MAT1GN63
4321MAT240524
4321MAT244636
4321MAT2XL524
4321MAT24X636
4321MAT2MN524
4321MAT2MO636
5443MAT3502516
5443MAT33XL2516
5443MAT3QQ2516

<tbody>
</tbody>


So instead of having up to 60 sizes distributed in 60 columns I want them in rows with their respective Doz quantity in 20 columns. Just like that, a monster table of 80+ columns can be simplified in 5 columns. In this new table, we could add as many sizes for an order as we want (since you can see they are limited to 20 , right now it is not a problem but we have future plans to increase the amount of sizes permitted and well, things will get really nasty)

It is worth noticing that not all orders can have all sizes filled. There are are orders, like the 5334 that just have a size in SizeA1, B1 and C1 and thus Doz1 is the only one filled.

How can I approach this in a VBA way? Or can pivots help me?
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,214,642
Messages
6,120,698
Members
448,979
Latest member
DET4492

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