Have a need to get a list of ingredients we will need based on a sequence list(schedule we will run) and an ingredient list. Here is simple list of data to show the tables I have and the output table based on these tables. I know it could be done with a macro but would prefer to have done with pivot table with calculated field. Have looked at several blogs on this a thought I was close but can not get to work.
[TABLE="width: 244"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]sequence[/TD]
[TD]Line Code[/TD]
[TD]Ordered QTY (ton)[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]4200001[/TD]
[TD="align: right"]47[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]4200002[/TD]
[TD="align: right"]22[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: right"]4200001[/TD]
[TD="align: right"]50[/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: right"]4200003[/TD]
[TD="align: right"]35
[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 272"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]Ingredient table
[/TD]
[/TR]
[TR]
[TD]Line Code ingredient Qty per ton
4200001 MILLET 1020.0
4200001 WHEAT 980.0
4200002 MILLET 600.0
4200002 WHEAT 500.0
4200002 STARCH 400.0
4200002 DEXTROSE 300.0
4200002 GELATIN 200.0
4200003 STARCH 1500.0
4200003 WHEAT 250.0
4200003 CARROT 250.0
This is what i want the output to be.
[TABLE="width: 631"]
<colgroup><col><col><col><col span="3"><col><col span="2"></colgroup><tbody>[TR]
[TD][TABLE="width: 631"]
<colgroup><col><col><col><col span="3"><col><col span="2"></colgroup><tbody>[TR]
[TD]sequence[/TD]
[TD]Line Code[/TD]
[TD]Ordered QTY[/TD]
[TD]MILLET[/TD]
[TD]WHEAT[/TD]
[TD]STARCH[/TD]
[TD]DEXTROSE[/TD]
[TD]GELATIN [/TD]
[TD]CARROT[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]4200001[/TD]
[TD="align: right"]47[/TD]
[TD="align: right"]47940[/TD]
[TD="align: right"]46060[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]4200002[/TD]
[TD="align: right"]22[/TD]
[TD="align: right"]13200[/TD]
[TD="align: right"]11000[/TD]
[TD="align: right"]8800[/TD]
[TD="align: right"]6600[/TD]
[TD="align: right"]4400[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: right"]4200001[/TD]
[TD="align: right"]50[/TD]
[TD="align: right"]51000[/TD]
[TD="align: right"]49000[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: right"]4200003[/TD]
[TD="align: right"]35[/TD]
[TD] [/TD]
[TD="align: right"]8750[/TD]
[TD="align: right"]52500[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]8750[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 244"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]sequence[/TD]
[TD]Line Code[/TD]
[TD]Ordered QTY (ton)[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]4200001[/TD]
[TD="align: right"]47[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]4200002[/TD]
[TD="align: right"]22[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: right"]4200001[/TD]
[TD="align: right"]50[/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: right"]4200003[/TD]
[TD="align: right"]35
[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 272"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]Ingredient table
[/TD]
[/TR]
[TR]
[TD]Line Code ingredient Qty per ton
4200001 MILLET 1020.0
4200001 WHEAT 980.0
4200002 MILLET 600.0
4200002 WHEAT 500.0
4200002 STARCH 400.0
4200002 DEXTROSE 300.0
4200002 GELATIN 200.0
4200003 STARCH 1500.0
4200003 WHEAT 250.0
4200003 CARROT 250.0
This is what i want the output to be.
[TABLE="width: 631"]
<colgroup><col><col><col><col span="3"><col><col span="2"></colgroup><tbody>[TR]
[TD][TABLE="width: 631"]
<colgroup><col><col><col><col span="3"><col><col span="2"></colgroup><tbody>[TR]
[TD]sequence[/TD]
[TD]Line Code[/TD]
[TD]Ordered QTY[/TD]
[TD]MILLET[/TD]
[TD]WHEAT[/TD]
[TD]STARCH[/TD]
[TD]DEXTROSE[/TD]
[TD]GELATIN [/TD]
[TD]CARROT[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]4200001[/TD]
[TD="align: right"]47[/TD]
[TD="align: right"]47940[/TD]
[TD="align: right"]46060[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]4200002[/TD]
[TD="align: right"]22[/TD]
[TD="align: right"]13200[/TD]
[TD="align: right"]11000[/TD]
[TD="align: right"]8800[/TD]
[TD="align: right"]6600[/TD]
[TD="align: right"]4400[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: right"]4200001[/TD]
[TD="align: right"]50[/TD]
[TD="align: right"]51000[/TD]
[TD="align: right"]49000[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: right"]4200003[/TD]
[TD="align: right"]35[/TD]
[TD] [/TD]
[TD="align: right"]8750[/TD]
[TD="align: right"]52500[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]8750[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]