averging prices real problem

A

amrezzat

heloo
if i have 5 columns like these

suppose that this is a sell and buy stocks forum
the first column is company number
the second column is company name
the third column is for quantity
the forth is for buy price
the fifth column is for sell price
as shwon belo

1 microsoft 100 50
2 sakhr
3 intel
1 microsoft 100 60
1 microsoft 100 (this is blank cell) 40
1 microsoft 100 40

and i want to average the price of the stock (for only the numer on
company (microsoft) )
so the result will be
((100*50+100*60)/(100+100))=55 (is the average price of the 20
stock)(downto the forth row)

then i sell 100 (in the fifth row)
so the result is
100 stock with average price 55
then i buy 100 with price 40
so the final result will be (100*55+100*40)/(100+100)=47.5
how can i do that in excel??
 
B

Bob Phillips

Surely, after the third Microsoft transaction, the average is still 50, as
you have had 300 transactions, 100 at 50, 100 at 60, 100 at 50.

But, this will get what you ask for.

In F1: =IF(A1=1,D1+E1,0)
F2: =(H1+IF(A2=1,D2+E2,0))/(IF(A2=1,1)+IF(H1>0,1))

and copy down

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
A

amrezzat

you seemed not read what i posted carefully

the problem is
i cant make the excel feel that i sold some shares as a result th
average will be wrong

what you posted will give not correct average
reconsider and come agai
 
G

Guest

You changed your 200 @ 55 to 100 @ 55 to come up with your answer.
((100*50+100*60)/(100+100))=55 (is the average price of the 200
(100*55+100*40)/(100+100)=47.5
Had you used =(200*55+100*40)/300 the answer would be 50.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top