Hi all - sorry for lots of text, I am struggling to explain this succinctly, but please read on.
I am trying to find a simple way to calculate the cost of a sale when an item is sold, based upon its purchase price which might vary during the year.
I have a spreadsheet of sales orders which runs into 15,000 over the last year and I am trying to make something more simple. currently, I have a sale per row; column B is quantity purchased, column C is a running count of the total product purchased (so C6=C5+B6 for example) and column D is the cost of this order.
On another spreadsheet page (Purchases) I list the product and any variation in price. From other data that populates with how many have been purchased at each price and the idea is to be specific about the cost of the product for the actual sale.
If sales are more than the total I purchased in order 1 then I need to add my purchase orders 1 & 2 together, but if sales are more than that total then I need to add order 3 and so on. When I get to a total of ordered product that is greater than the total of sold, I can then use the cost of the item in the relevant order to calculate the cost of the sale.
I have attached a simple example of the query and I am looking to automate the process by way off function to resolve column D
Any help towards a sensible formula to work that out so I can copy it into every row in the table would be greatly appreciated, thank you.
regards and thanks for reading
Cpl Smudge
Bookmarks