I need to create a fifo function for price calculation.
I have a table with the following layout:
Purchase_date Quantity Purchase_Price
----------------------------------------
2011-01-01 1000 10
2011-01-02 2000 11
......
Sale_date Quantity Costprice
----------------------------------------
2011-02-01 50 =fifo_costprice(...
the Fifo formula works like:
fifo_costprice(Q_sold_to_date as float, Quantity_purchased as range
, Purchase_Prices as range) as float
How do I do this in Excel VBA?
Here’s what I came up with to start, it doesn’t do any error checking and date matching, but it works.