I have as sheet in which I'm storing inventory purchase date, quantity and rate. In a separate sheet I'm tracking the export of the inventory. Hence, I'm able to compute the total purchases made till date and the total exports done. The difference of the two are the stock in hand. I need to compute the average purchase rate of the stock in hand on FIFO basis.