Copy Data from 2 pivot table and make a new data set......

sasils

New Member
Joined
Jun 3, 2017
Messages
24
Hi,

I need help on VBA code to copy and merge data from 2 pivot tables into a single data set to be display in another sheet.

Below is data Sheet 1 in excel.

[TABLE="width: 388"]
<colgroup><col span="2"><col><col><col></colgroup><tbody>[TR]
[TD="align: left"]Pivot A[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD="align: left"]Shipto[/TD]
[TD="align: left"]Soldto[/TD]
[TD="align: left"]LV1[/TD]
[TD="align: left"]LV2[/TD]
[TD="align: left"]LV3[/TD]
[/TR]
[TR]
[TD="align: left"]001[/TD]
[TD="align: left"]A[/TD]
[TD="align: left"]Local[/TD]
[TD="align: left"]NE[/TD]
[TD="align: left"]Manufacturer[/TD]
[/TR]
[TR]
[TD="align: left"]002[/TD]
[TD="align: left"]B[/TD]
[TD="align: left"]Local[/TD]
[TD="align: left"]NE[/TD]
[TD="align: left"]Manufacturer[/TD]
[/TR]
[TR]
[TD="align: left"]003[/TD]
[TD="align: left"]C[/TD]
[TD="align: left"]Global[/TD]
[TD="align: left"]CE[/TD]
[TD="align: left"]Trader[/TD]
[/TR]
[TR]
[TD="align: left"]004[/TD]
[TD="align: left"]D[/TD]
[TD="align: left"]Global[/TD]
[TD="align: left"]CE[/TD]
[TD="align: left"]Whole Sale[/TD]
[/TR]
[TR]
[TD="align: left"]005[/TD]
[TD="align: left"]E[/TD]
[TD="align: left"]Others[/TD]
[TD="align: left"]S[/TD]
[TD="align: left"]Mini Mart[/TD]
[/TR]
[TR]
[TD="align: left"]006[/TD]
[TD="align: left"]E[/TD]
[TD="align: left"]Others[/TD]
[TD="align: left"]S[/TD]
[TD="align: left"]Mini Mart[/TD]
[/TR]
</tbody>[/TABLE]


[TABLE="width: 305"]
<colgroup><col><col><col><col></colgroup><tbody>[TR]
[TD="align: left"]Pivot B[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD="align: left"]Mat Code[/TD]
[TD="align: left"]Description[/TD]
[TD="align: left"]LV1[/TD]
[TD="align: left"]LV2[/TD]
[/TR]
[TR]
[TD="align: left"]S001[/TD]
[TD="align: left"]AAA[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: left"]S002[/TD]
[TD="align: left"]BBB[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: left"]S003[/TD]
[TD="align: left"]CCC[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: left"]S004[/TD]
[TD="align: left"]DDD[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: left"]S005[/TD]
[TD="align: left"]EEE[/TD]
[TD="align: left"]Paper[/TD]
[TD="align: left"]PM[/TD]
[/TR]
[TR]
[TD="align: left"]S006[/TD]
[TD="align: left"]FFF[/TD]
[TD="align: left"]Paper[/TD]
[TD="align: left"]PM[/TD]
[/TR]
</tbody>[/TABLE]

Final Data to use data from Pivot A and B into a data set in Sheet 2. The result should look like below.

[TABLE="width: 665"]
<colgroup><col><col><col><col><col><col span="4"></colgroup><tbody>[TR]
[TD="align: left"]Final Table[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: left"]Shipto[/TD]
[TD="align: left"]Soldto[/TD]
[TD="align: left"]LV1[/TD]
[TD="align: left"]LV2[/TD]
[TD="align: left"]LV3[/TD]
[TD="align: left"]Mat Code[/TD]
[TD="align: left"]Description[/TD]
[TD="align: left"]LV1[/TD]
[TD="align: left"]LV2[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: left"]A[/TD]
[TD="align: left"]Local[/TD]
[TD="align: left"]NE[/TD]
[TD="align: left"]Manufacturer[/TD]
[TD="align: left"]S001[/TD]
[TD="align: left"]AAA[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: left"]A[/TD]
[TD="align: left"]Local[/TD]
[TD="align: left"]NE[/TD]
[TD="align: left"]Manufacturer[/TD]
[TD="align: left"]S002[/TD]
[TD="align: left"]BBB[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: left"]A[/TD]
[TD="align: left"]Local[/TD]
[TD="align: left"]NE[/TD]
[TD="align: left"]Manufacturer[/TD]
[TD="align: left"]S003[/TD]
[TD="align: left"]CCC[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: left"]A[/TD]
[TD="align: left"]Local[/TD]
[TD="align: left"]NE[/TD]
[TD="align: left"]Manufacturer[/TD]
[TD="align: left"]S004[/TD]
[TD="align: left"]DDD[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: left"]A[/TD]
[TD="align: left"]Local[/TD]
[TD="align: left"]NE[/TD]
[TD="align: left"]Manufacturer[/TD]
[TD="align: left"]S005[/TD]
[TD="align: left"]EEE[/TD]
[TD="align: left"]Paper[/TD]
[TD="align: left"]PM[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: left"]A[/TD]
[TD="align: left"]Local[/TD]
[TD="align: left"]NE[/TD]
[TD="align: left"]Manufacturer[/TD]
[TD="align: left"]S006[/TD]
[TD="align: left"]FFF[/TD]
[TD="align: left"]Paper[/TD]
[TD="align: left"]PM[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: left"]B[/TD]
[TD="align: left"]Local[/TD]
[TD="align: left"]NE[/TD]
[TD="align: left"]Manufacturer[/TD]
[TD="align: left"]S001[/TD]
[TD="align: left"]AAA[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: left"]B[/TD]
[TD="align: left"]Local[/TD]
[TD="align: left"]NE[/TD]
[TD="align: left"]Manufacturer[/TD]
[TD="align: left"]S002[/TD]
[TD="align: left"]BBB[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: left"]B[/TD]
[TD="align: left"]Local[/TD]
[TD="align: left"]NE[/TD]
[TD="align: left"]Manufacturer[/TD]
[TD="align: left"]S003[/TD]
[TD="align: left"]CCC[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: left"]B[/TD]
[TD="align: left"]Local[/TD]
[TD="align: left"]NE[/TD]
[TD="align: left"]Manufacturer[/TD]
[TD="align: left"]S004[/TD]
[TD="align: left"]DDD[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: left"]B[/TD]
[TD="align: left"]Local[/TD]
[TD="align: left"]NE[/TD]
[TD="align: left"]Manufacturer[/TD]
[TD="align: left"]S005[/TD]
[TD="align: left"]EEE[/TD]
[TD="align: left"]Paper[/TD]
[TD="align: left"]PM[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: left"]B[/TD]
[TD="align: left"]Local[/TD]
[TD="align: left"]NE[/TD]
[TD="align: left"]Manufacturer[/TD]
[TD="align: left"]S006[/TD]
[TD="align: left"]FFF[/TD]
[TD="align: left"]Paper[/TD]
[TD="align: left"]PM[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: left"]C[/TD]
[TD="align: left"]Global[/TD]
[TD="align: left"]CE[/TD]
[TD="align: left"]Trader[/TD]
[TD="align: left"]S001[/TD]
[TD="align: left"]AAA[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: left"]C[/TD]
[TD="align: left"]Global[/TD]
[TD="align: left"]CE[/TD]
[TD="align: left"]Trader[/TD]
[TD="align: left"]S002[/TD]
[TD="align: left"]BBB[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: left"]C[/TD]
[TD="align: left"]Global[/TD]
[TD="align: left"]CE[/TD]
[TD="align: left"]Trader[/TD]
[TD="align: left"]S003[/TD]
[TD="align: left"]CCC[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: left"]C[/TD]
[TD="align: left"]Global[/TD]
[TD="align: left"]CE[/TD]
[TD="align: left"]Trader[/TD]
[TD="align: left"]S004[/TD]
[TD="align: left"]DDD[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: left"]C[/TD]
[TD="align: left"]Global[/TD]
[TD="align: left"]CE[/TD]
[TD="align: left"]Trader[/TD]
[TD="align: left"]S005[/TD]
[TD="align: left"]EEE[/TD]
[TD="align: left"]Paper[/TD]
[TD="align: left"]PM[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: left"]C[/TD]
[TD="align: left"]Global[/TD]
[TD="align: left"]CE[/TD]
[TD="align: left"]Trader[/TD]
[TD="align: left"]S006[/TD]
[TD="align: left"]FFF[/TD]
[TD="align: left"]Paper[/TD]
[TD="align: left"]PM[/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: left"]D[/TD]
[TD="align: left"]Global[/TD]
[TD="align: left"]CE[/TD]
[TD="align: left"]Whole Sale[/TD]
[TD="align: left"]S001[/TD]
[TD="align: left"]AAA[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: left"]D[/TD]
[TD="align: left"]Global[/TD]
[TD="align: left"]CE[/TD]
[TD="align: left"]Whole Sale[/TD]
[TD="align: left"]S002[/TD]
[TD="align: left"]BBB[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: left"]D[/TD]
[TD="align: left"]Global[/TD]
[TD="align: left"]CE[/TD]
[TD="align: left"]Whole Sale[/TD]
[TD="align: left"]S003[/TD]
[TD="align: left"]CCC[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: left"]D[/TD]
[TD="align: left"]Global[/TD]
[TD="align: left"]CE[/TD]
[TD="align: left"]Whole Sale[/TD]
[TD="align: left"]S004[/TD]
[TD="align: left"]DDD[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: left"]D[/TD]
[TD="align: left"]Global[/TD]
[TD="align: left"]CE[/TD]
[TD="align: left"]Whole Sale[/TD]
[TD="align: left"]S005[/TD]
[TD="align: left"]EEE[/TD]
[TD="align: left"]Paper[/TD]
[TD="align: left"]PM[/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: left"]D[/TD]
[TD="align: left"]Global[/TD]
[TD="align: left"]CE[/TD]
[TD="align: left"]Whole Sale[/TD]
[TD="align: left"]S006[/TD]
[TD="align: left"]FFF[/TD]
[TD="align: left"]Paper[/TD]
[TD="align: left"]PM[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD="align: left"]E[/TD]
[TD="align: left"]Others[/TD]
[TD="align: left"]S[/TD]
[TD="align: left"]Mini Mart[/TD]
[TD="align: left"]S001[/TD]
[TD="align: left"]AAA[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD="align: left"]E[/TD]
[TD="align: left"]Others[/TD]
[TD="align: left"]S[/TD]
[TD="align: left"]Mini Mart[/TD]
[TD="align: left"]S002[/TD]
[TD="align: left"]BBB[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD="align: left"]E[/TD]
[TD="align: left"]Others[/TD]
[TD="align: left"]S[/TD]
[TD="align: left"]Mini Mart[/TD]
[TD="align: left"]S003[/TD]
[TD="align: left"]CCC[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD="align: left"]E[/TD]
[TD="align: left"]Others[/TD]
[TD="align: left"]S[/TD]
[TD="align: left"]Mini Mart[/TD]
[TD="align: left"]S004[/TD]
[TD="align: left"]DDD[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD="align: left"]E[/TD]
[TD="align: left"]Others[/TD]
[TD="align: left"]S[/TD]
[TD="align: left"]Mini Mart[/TD]
[TD="align: left"]S005[/TD]
[TD="align: left"]EEE[/TD]
[TD="align: left"]Paper[/TD]
[TD="align: left"]PM[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD="align: left"]E[/TD]
[TD="align: left"]Others[/TD]
[TD="align: left"]S[/TD]
[TD="align: left"]Mini Mart[/TD]
[TD="align: left"]S006[/TD]
[TD="align: left"]FFF[/TD]
[TD="align: left"]Paper[/TD]
[TD="align: left"]PM[/TD]
[/TR]
[TR]
[TD="align: right"]6[/TD]
[TD="align: left"]E[/TD]
[TD="align: left"]Others[/TD]
[TD="align: left"]S[/TD]
[TD="align: left"]Mini Mart[/TD]
[TD="align: left"]S001[/TD]
[TD="align: left"]AAA[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]6[/TD]
[TD="align: left"]E[/TD]
[TD="align: left"]Others[/TD]
[TD="align: left"]S[/TD]
[TD="align: left"]Mini Mart[/TD]
[TD="align: left"]S002[/TD]
[TD="align: left"]BBB[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]6[/TD]
[TD="align: left"]E[/TD]
[TD="align: left"]Others[/TD]
[TD="align: left"]S[/TD]
[TD="align: left"]Mini Mart[/TD]
[TD="align: left"]S003[/TD]
[TD="align: left"]CCC[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]6[/TD]
[TD="align: left"]E[/TD]
[TD="align: left"]Others[/TD]
[TD="align: left"]S[/TD]
[TD="align: left"]Mini Mart[/TD]
[TD="align: left"]S004[/TD]
[TD="align: left"]DDD[/TD]
[TD="align: left"]Chemical[/TD]
[TD="align: left"]RM[/TD]
[/TR]
[TR]
[TD="align: right"]6[/TD]
[TD="align: left"]E[/TD]
[TD="align: left"]Others[/TD]
[TD="align: left"]S[/TD]
[TD="align: left"]Mini Mart[/TD]
[TD="align: left"]S005[/TD]
[TD="align: left"]EEE[/TD]
[TD="align: left"]Paper[/TD]
[TD="align: left"]PM[/TD]
[/TR]
[TR]
[TD="align: right"]6[/TD]
[TD="align: left"]E[/TD]
[TD="align: left"]Others[/TD]
[TD="align: left"]S[/TD]
[TD="align: left"]Mini Mart[/TD]
[TD="align: left"]S006[/TD]
[TD="align: left"]FFF[/TD]
[TD="align: left"]Paper[/TD]
[TD="align: left"]PM[/TD]
[/TR]
</tbody>[/TABLE]

Thank you so much for your help.

Cheers.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Similar threads

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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