This proposed solution adds a helper table (AK:AX) populated by the array entered formula*:
Formula:
=IF(MATCH(1,$V3:$AI3,0)>COLUMN()-COLUMN($AJ3),B3,IF(V3=1,SUM($B3:B3)-SUM($AJ3:AJ3),0))
The array entered formula* that populates column S (sold) is:
Formula:
=SUM(INDEX(AK3:AX3,MATCH(1,V3:AI3,0)),INDEX(AK3:AX3,SMALL(IF(V3:AI3=1,COLUMN(B:O)-1),2)))
*Array entered formulas are activated by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.
Note: The conditional formatting applied to the helper table is not needed, however it may help to explain from where the numbers come, as in:
Green -- Sales table
Blue -- Sales table corresponding to values of one on the Delivery Schedule table
Pink -- Delivery Schedule table
Let us know if you have any questions.
Bookmarks