Averaging

riskier4ra

Board Regular
Joined
Dec 5, 2017
Messages
101
Hi, anyone have an idea on how I can get these formulas to work as one.

I am trying to get an average on stock price. I found an excel sheet that was using the following formula
=IF(OR(D22="err",D23="err"),"err",D22/D23)

D22 = Total Cost = =IF(OR(D8="err",D12="err",D16="err",D20="err"),"err",SUM(D8,D12,D16,D20))
D33 = Total Shares = =IF(OR(C8<0,C12<0,C16<0,C20<0),"err",C6+C10+C14+C18)

I also have my own that works using this formula
IFERROR(ABS(AVERAGEIF(E18:G27,E7,G18:G27)),0)

In E:18:G27 = Symbol, #Shares , Buy Price
E7 = Symbol

The reason I am trying to figure out how to merge them is because the 1st one actually gives a correct average when adding new buys.

Mine doesnt seem to work right.

To use the 1st option I would have to reformat my page. Not a good solution for me. I simply want the formula to look at E18:G27, find the symbols = E7, its #of shares, sum up the buy price of what is found, then divide the total cost against the total shares. Is this possible?

Thanks - Risk
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
how about this?


Book1
EFG
7#of12.5
17
1810
1910
20#of10
21#of10
2210
2310
24#of20
2510
2610
27#of10
Sheet1
Cell Formulas
RangeFormula
G7=AVERAGEIF(E18:E27,E7,G18:G27)
 
Upvote 0
No that doesnt work.

Gives me the same result.

I need it to look at the range, find the symbol I select in a drop down, sum up the total buy price, sum up the total number of shares, then divide them to give me the average.
 
Upvote 0
can you post a small sample of your data here?
 
Upvote 0
unfortunately, you can't attach files here. you can share them on goggle drive or similar
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,331
Members
449,077
Latest member
jmsotelo

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