I downloaded your sheet and found that it would not properly sum. So I recreated it from "nearly scratch. The cost for an line item is calculated as the total cost of all items ($200) times the number of units in the line item all divided by the total of all the units in all of the line items. Hopefully you can get to my copy of your spreadsheet here : https://docs.google.com/spreadsheets/d/1yP7bFN-vV5W3RAPUSt3VSdDhE9JF2rWZV9lLTHi0_8c/edit?gid=0#gid=0