I have a set of data as shown in the table below that I need to showcase in the format as shown in the 2nd table.
But a little background first: In the table below we used a typical format for customer data, where each unique combination of data had its own row, so if Customer 12345 had US locations and ordered 2 different products, we would showcase this information over 2 lines. And if Customer 12346 only bought 1 product, but for 4 different locations it would consist of 4 separate lines. See the 1st table for an example.
How the data is currently displayed:
[TABLE="class: grid, width: 400"]
<tbody>[TR]
[TD]Customer[/TD]
[TD]Location(s)[/TD]
[TD]Product[/TD]
[TD]Sales Rep[/TD]
[/TR]
[TR]
[TD]12345[/TD]
[TD]United States[/TD]
[TD]412[/TD]
[TD]John[/TD]
[/TR]
[TR]
[TD]12345[/TD]
[TD]United States[/TD]
[TD]413[/TD]
[TD]John[/TD]
[/TR]
[TR]
[TD]12346[/TD]
[TD]Germany[/TD]
[TD]416[/TD]
[TD]Matt[/TD]
[/TR]
[TR]
[TD]12346[/TD]
[TD]United States[/TD]
[TD]416[/TD]
[TD]Matt[/TD]
[/TR]
[TR]
[TD]12346[/TD]
[TD]Poland[/TD]
[TD]416[/TD]
[TD]Matt[/TD]
[/TR]
[TR]
[TD]12346[/TD]
[TD]Mexico[/TD]
[TD]416[/TD]
[TD]Matt[/TD]
[/TR]
[TR]
[TD]12348[/TD]
[TD]Mexico[/TD]
[TD]413[/TD]
[TD]Dan[/TD]
[/TR]
[TR]
[TD]12348[/TD]
[TD]Germany[/TD]
[TD]413[/TD]
[TD]Dan[/TD]
[/TR]
[TR]
[TD]12348[/TD]
[TD]Mexico[/TD]
[TD]689[/TD]
[TD]Dan[/TD]
[/TR]
[TR]
[TD]12348[/TD]
[TD]Germany[/TD]
[TD]689[/TD]
[TD]Dan[/TD]
[/TR]
</tbody>[/TABLE]
But due to a pending system move we need to alter our customer data into an alternative structure to be uploaded to the new system, and it needs to be in the format shown in the table below. I'm at a loss at how to restructure this via VBA as the new format is so bizarre in my opinion. My only thought is to separate the data into 3 tables (customer & location, customer & product, customer & sales rep) then insert blank rows manually for the number of locations and product for each unique customer/sales combo.
How I need the data to look:
[TABLE="class: grid, width: 400"]
<tbody>[TR]
[TD]Customer[/TD]
[TD]Location[/TD]
[TD]Product[/TD]
[TD]Sales Rep[/TD]
[/TR]
[TR]
[TD="align: right"]12345[/TD]
[TD]United States[/TD]
[TD="align: right"]412[/TD]
[TD="align: right"]John[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD="align: right"]413[/TD]
[TD="align: right"][/TD]
[/TR]
[TR]
[TD="align: right"]12346[/TD]
[TD]Germany[/TD]
[TD="align: right"]416[/TD]
[TD="align: right"]Matt[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]United States[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Poland[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Mexico[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]12348[/TD]
[TD]Mexico[/TD]
[TD="align: right"]413[/TD]
[TD="align: right"]Dan[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Germany[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD="align: right"]689[/TD]
[TD="align: right"][/TD]
[/TR]
</tbody>[/TABLE]
Any thoughts on how this could be done via VBA or in a more automated manner? Happy to answer any questions.
But a little background first: In the table below we used a typical format for customer data, where each unique combination of data had its own row, so if Customer 12345 had US locations and ordered 2 different products, we would showcase this information over 2 lines. And if Customer 12346 only bought 1 product, but for 4 different locations it would consist of 4 separate lines. See the 1st table for an example.
How the data is currently displayed:
[TABLE="class: grid, width: 400"]
<tbody>[TR]
[TD]Customer[/TD]
[TD]Location(s)[/TD]
[TD]Product[/TD]
[TD]Sales Rep[/TD]
[/TR]
[TR]
[TD]12345[/TD]
[TD]United States[/TD]
[TD]412[/TD]
[TD]John[/TD]
[/TR]
[TR]
[TD]12345[/TD]
[TD]United States[/TD]
[TD]413[/TD]
[TD]John[/TD]
[/TR]
[TR]
[TD]12346[/TD]
[TD]Germany[/TD]
[TD]416[/TD]
[TD]Matt[/TD]
[/TR]
[TR]
[TD]12346[/TD]
[TD]United States[/TD]
[TD]416[/TD]
[TD]Matt[/TD]
[/TR]
[TR]
[TD]12346[/TD]
[TD]Poland[/TD]
[TD]416[/TD]
[TD]Matt[/TD]
[/TR]
[TR]
[TD]12346[/TD]
[TD]Mexico[/TD]
[TD]416[/TD]
[TD]Matt[/TD]
[/TR]
[TR]
[TD]12348[/TD]
[TD]Mexico[/TD]
[TD]413[/TD]
[TD]Dan[/TD]
[/TR]
[TR]
[TD]12348[/TD]
[TD]Germany[/TD]
[TD]413[/TD]
[TD]Dan[/TD]
[/TR]
[TR]
[TD]12348[/TD]
[TD]Mexico[/TD]
[TD]689[/TD]
[TD]Dan[/TD]
[/TR]
[TR]
[TD]12348[/TD]
[TD]Germany[/TD]
[TD]689[/TD]
[TD]Dan[/TD]
[/TR]
</tbody>[/TABLE]
But due to a pending system move we need to alter our customer data into an alternative structure to be uploaded to the new system, and it needs to be in the format shown in the table below. I'm at a loss at how to restructure this via VBA as the new format is so bizarre in my opinion. My only thought is to separate the data into 3 tables (customer & location, customer & product, customer & sales rep) then insert blank rows manually for the number of locations and product for each unique customer/sales combo.
How I need the data to look:
[TABLE="class: grid, width: 400"]
<tbody>[TR]
[TD]Customer[/TD]
[TD]Location[/TD]
[TD]Product[/TD]
[TD]Sales Rep[/TD]
[/TR]
[TR]
[TD="align: right"]12345[/TD]
[TD]United States[/TD]
[TD="align: right"]412[/TD]
[TD="align: right"]John[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD="align: right"]413[/TD]
[TD="align: right"][/TD]
[/TR]
[TR]
[TD="align: right"]12346[/TD]
[TD]Germany[/TD]
[TD="align: right"]416[/TD]
[TD="align: right"]Matt[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]United States[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Poland[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Mexico[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]12348[/TD]
[TD]Mexico[/TD]
[TD="align: right"]413[/TD]
[TD="align: right"]Dan[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Germany[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD="align: right"]689[/TD]
[TD="align: right"][/TD]
[/TR]
</tbody>[/TABLE]
Any thoughts on how this could be done via VBA or in a more automated manner? Happy to answer any questions.