Hi All,
I have a spreadsheet with details of shares bought and sold, I have an add-in that calculates the current prices and everything is working fine but I would like to add a NET COST cell that calculates the cost of shares currently in my possession.
The below example data is transactional and chronological from top to bottom, so a positive Qty is a buy and a negative Qty is a sell. From the below data I have been calculating a net cost using a sumif formula that excludes negative "Qty Bought/Sold" values (those are sell orders), giving me a net cost of $12,154. However, I now want to calculate the net cost of shares currently in my possession (the correct value is $4,170), which means that I need to subtract the Qty sold, but multiply it by the buy price (not the sell price which is in the adjacent cell). I am working under the assumption of "First in, first out" whereby I am assuming that I am selling the oldest buy order each time.
Hope this makes sense, if anyone has any thoughts on how to do this please let me know! I can add a column to the right of the Price Bought/Sold column to calculate if that is easier, but would prefer it to calculate in one cell (assume that is impossible though). Prefer to use formulas rather than VBA if possible.
Example data (rows are in chronological order):
Net Cost (?)
[TABLE="width: 250"]
<tbody>[TR]
[TD]Qty Bought/Sold
[/TD]
[TD]Price Bought/Sold
[/TD]
[/TR]
[TR]
[TD]20,600
[/TD]
[TD]$0.24
[/TD]
[/TR]
[TR]
[TD]8,000
[/TD]
[TD]$0.38
[/TD]
[/TR]
[TR]
[TD]-20,600
[/TD]
[TD]$0.40
[/TD]
[/TR]
[TR]
[TD]-8,000
[/TD]
[TD]$0.35
[/TD]
[/TR]
[TR]
[TD]8,000
[/TD]
[TD]$0.37
[/TD]
[/TR]
[TR]
[TD]2,000
[/TD]
[TD]$0.28
[/TD]
[/TR]
[TR]
[TD]2,500
[/TD]
[TD]$0.26
[/TD]
[/TR]
</tbody>[/TABLE]
Thanks all!
I have a spreadsheet with details of shares bought and sold, I have an add-in that calculates the current prices and everything is working fine but I would like to add a NET COST cell that calculates the cost of shares currently in my possession.
The below example data is transactional and chronological from top to bottom, so a positive Qty is a buy and a negative Qty is a sell. From the below data I have been calculating a net cost using a sumif formula that excludes negative "Qty Bought/Sold" values (those are sell orders), giving me a net cost of $12,154. However, I now want to calculate the net cost of shares currently in my possession (the correct value is $4,170), which means that I need to subtract the Qty sold, but multiply it by the buy price (not the sell price which is in the adjacent cell). I am working under the assumption of "First in, first out" whereby I am assuming that I am selling the oldest buy order each time.
Hope this makes sense, if anyone has any thoughts on how to do this please let me know! I can add a column to the right of the Price Bought/Sold column to calculate if that is easier, but would prefer it to calculate in one cell (assume that is impossible though). Prefer to use formulas rather than VBA if possible.
Example data (rows are in chronological order):
Net Cost (?)
[TABLE="width: 250"]
<tbody>[TR]
[TD]Qty Bought/Sold
[/TD]
[TD]Price Bought/Sold
[/TD]
[/TR]
[TR]
[TD]20,600
[/TD]
[TD]$0.24
[/TD]
[/TR]
[TR]
[TD]8,000
[/TD]
[TD]$0.38
[/TD]
[/TR]
[TR]
[TD]-20,600
[/TD]
[TD]$0.40
[/TD]
[/TR]
[TR]
[TD]-8,000
[/TD]
[TD]$0.35
[/TD]
[/TR]
[TR]
[TD]8,000
[/TD]
[TD]$0.37
[/TD]
[/TR]
[TR]
[TD]2,000
[/TD]
[TD]$0.28
[/TD]
[/TR]
[TR]
[TD]2,500
[/TD]
[TD]$0.26
[/TD]
[/TR]
</tbody>[/TABLE]
Thanks all!