Thank you so much Peter. I am very impressed and I used the second option. As you noticed cleary, I needed to populate all the other cells in the same column E. Once again I am amazed. A question: after the aggregate function you put 14,6; are these function numbers for Large and Product? That's quit some rocket science here.
| A | B | C | D | E |
Description | Opening Stock Level | | | | |
Sugar | Unknown | | | | |
Corn | Unknown | | | | |
Corn | | | | | |
Sugar | | | | | |
Salt | Unknown | | | | |
Salt | | | | | |
Corn | | | | | |
Sugar | | | | | |
<colgroup><col style="font-weight:bold; width:30px; "><col style="width:84px;"><col style="width:140px;"><col style="width:77px;"><col style="width:83px;"><col style="width:85px;"></colgroup><tbody>
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]1[/TD]
[TD="align: right"]Reception[/TD]
[TD="align: right"]Withdrawal[/TD]
[TD="align: right"]Stock Final[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]2[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]500[/TD]
[TD="align: right"]1,000[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]3[/TD]
[TD="align: right"]14000[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]69,000[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]4[/TD]
[TD="align: right"]69000[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]8,000[/TD]
[TD="align: right"]61,000[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]5[/TD]
[TD="align: right"]1000[/TD]
[TD="align: right"]20,000[/TD]
[TD="align: right"]5,000[/TD]
[TD="align: right"]16,000[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]6[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]30,000[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]7[/TD]
[TD="align: right"]30000[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]2,500[/TD]
[TD="align: right"]27,500[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]8[/TD]
[TD="align: right"]61000[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]14,000[/TD]
[TD="align: right"]47,000[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]9[/TD]
[TD="align: right"]16000[/TD]
[TD="align: right"]2,000[/TD]
[TD="align: right"]3,000[/TD]
[TD="align: right"]15,000[/TD]
</tbody>
.. or if the formula is to be pre-populated further down the column, try
IFERROR(INDEX(E$1:E1,AGGREGATE(14,6,(ROW(E$1:E1)-ROW(E$1)+1)/(A$1:A1=A2),1)),E2+D2-C2)