Buy and sell formula problems

bwinnard

New Member
Joined
Apr 14, 2003
Messages
34
I have a list of inventory that I buy and sell. I want to be able to pair them together appropriately to determine the profit/loss. For instance...

Item A..buy$
Item B..buy$
Item A..buy$
Item A..sell$
Item B..sell$

In the above case, I want the first "Item A Buy$" to subtract from the first "Item A Sell$" and then be finished with them, put aside elsewhere if possible (since the list changes daily).

Any suggestions?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Use sumif;

Code:
=SUMIF(B1:B8,"buy",C1:C8)-SUMIF(B1:B8,"sell",C1:C8)

B1:B8 is buy/sell
C1:C8 is the numbers
 
Upvote 0
not exactly..i want to differentiate between the each buy/sell pairing of item a and item b seperately

any ideas?
 
Upvote 0
I think in order to answer your question, we might need a bit more detail as to exactly what out of "Item A..buy$" are in which cells. For instance, Item ID (name, part number, ticker) in column A, Buy/Sell in column B, Amounts in column C ...
 
Upvote 0
Ok so what I want to do is sum the prices sort of like a FIFO method. For instance, I want to keep the first Item A buy & sell distinct from the 2nd, 3rd, (and so on) incident of buy & sell.




Col I.....Col II.................Col III
date1....Item A desc.......buy price (-5$)
date2....Item B desc.......buy price (-3$)
date3....Item A desc......buy price (-9$)
date4....Item A desc.......sell price ($10)
date5....Item B desc.......sell price ($15)

So in this case, I want to show the first occurance of item A was $5 (10-5)
And the Item B transaction was $12 (15-3)
 
Upvote 0
What about this format? Start the day with the only the Date and Seq columns filled in, with the Seq column being sequential 1 to n.

As buys occur, add them in the first row where Item is open. Set a sort for all rows in your table as Date, Item, Seq and sort the list every time you Buy a new lot.

The Seq column will keep your Buys in FIFO order, while the main list is in Item order.

For Sells, find the first open Sell cell for the item and enter that price. The Total column subtracts Buy from Sell giving your answer.

I hope this isn't too simple a reading of the problem.
Book2
ABCDEFGH
1DateItemSeqBuySellTotal
29-AugA15105
39-AugA59-9
49-AugA610-10
59-AugB231512
69-AugB30
79-AugB40
89-Aug70
99-Aug80
109-Aug90
119-Aug100
12
13
Sheet1
 
Upvote 0
Not sure if you've gotten your solution, but I'm still :oops: trying to write a FIFO/LIFO formula -- it has become a personal challenge, now. will try to post back when i have the time.
 
Upvote 0
I'm playing around with Edell's solution, but if you can get a FIFO/LIFO sheet, I would forever be grateful.
 
Upvote 0
I had a single-cell formula in mind, but I thnk it would fail if there were ever 2 buys/sells of the same item on the same day; this example, with the extra column added (can be hidden, put on another page), seems to work.
tester1.xls
ABCDEF
1TransDateDescriptionAmountNetProfit/LossCount/Rank
201-Jan-03ItemAdesc$(5.00)ItemSold1
302-Feb-03ItemCdesc$(7.50)ItemSold1
405-Mar-03ItemBdesc$(8.66)ItemSold1
502-Feb-03ItemXdesc$(3.00)IteminStock1
603-Mar-03ItemAdesc$(9.00)ItemSold2
704-Mar-03ItemAdesc$10.00$5.001
807-Jun-03ItemAdesc$15.00$6.002
907-Jul-03ItemCdesc$11.00$3.501
1008-Aug-03ItemBdesc$8.00$(0.66)1
1109-Sep-03ItemZDesc$(15.50)IteminStock1
1210-Oct-03ItemQdesc$22.11Error:NotinStock!1
Sheet2


Formulas are--
in D2, dragged down: =IF(AND($C2<0,(SUMPRODUCT(($B$2:$B$20=B2)*($C$2:$C$20<0))<=SUMPRODUCT(($B$2:$B$20=$B2)*($C$2:$C$20>0)))),"Item Sold",IF($C2<0,"Item in Stock",IF(AND($C2>0,SUMPRODUCT(($B$2:$B$20=B2)*($C$2:$C$20<0))<SUMPRODUCT(($B$2:$B$20=$B2)*($C$2:$C$20>0))),"Error: Not in Stock!",IF(LEN($C2),$C2+SUMPRODUCT(($B$2:$B$20=$B2)*($C$2:$C$20<0)*($F$2:$F$20=$F2),($C$2:$C$20)),""))))

in F2, dragged down: =IF($C2<0,SUMPRODUCT(($B$2:$B2=$B2)*($C$2:$C2<0)),IF(LEN($C2),SUMPRODUCT(($B$2:$B2=$B2)*($C$2:$C2>0)),""))

Gawd, that looks hideous! :rolleyes:
 
Upvote 0
If you are amenable to reorganizing your data to:
Code:
Item #	Item Desc	Buy Date	Buy Cost	Sale Date	Sale Price
you would get two benefits: finding the first unsold unit of an item will be easy; it will completely eliminate the risk of mismatches because of typos.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,552
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top