Average specific value if listed on any worksheet

gtd526

Well-known Member
Joined
Jul 30, 2013
Messages
675
Office Version
  1. 2019
Platform
  1. Windows
Hello,
Im able to average a certain range (L:L) for ALL spreadsheets in workbook ie AVERAGE('Schwab:401k'!$L$9:$L$15)
Want to average only a single symbol (TECL) if its present on any spreadsheet. It could be listed multiple times on a single sheet.
I've tried a couple of different formulas, but no luck (C33 & C34).
Thank you.

Sample:
The Whole Enchilada.xlsm
ABC
3214.50%Average for ALL sheets for L:L Range
33TECL#REF!
34Schwab52.11%#VALUE!
35Roth IRA18.08%
36AMTD-0.98%
37401k1.64%
Capital Gains Tax
Cell Formulas
RangeFormula
B32B32=AVERAGE('Schwab:401k'!$L$9:$L$15)
C33C33=IF('Schwab:401k'!$A$9:$A$15="TECL",AVERAGE('Schwab:401k'!$L$9:$L$15),"Wrong")
C34C34=IF(INDIRECT("'"&A34&"'"&"!"&"A9:A15")="TECL",AVERAGE(INDIRECT("'"&A34&"'"&"!"&"L9:L15")),"Wrong")
B34B34=AVERAGE(INDIRECT("'"&A34&"'"&"!"&"L9:L15"))
B35:B37B35=AVERAGE(INDIRECT("'"&A35&"'"&"!"&"A9:A15"),INDIRECT("'"&A35&"'"&"!"&"L9:L15"))
Press CTRL+SHIFT+ENTER to enter array formulas.


First Spreadsheet:
The Whole Enchilada.xlsm
ABCDEFGHIJKL
8 Symbol Sector Type Shares Price CURRENT MAX Value MIN Value Cost ValueMarket ValueGain/LossG/L %
9TECLTech 3XLong86$27.83$54.02$54.02$49.49$2,393.38$ 4,645.72$ 2,252.3494.11%
10FASFinance 3xLong13$57.74$63.58$63.58$58.51$750.62$ 826.54$ 75.9210.11%
11       
12       
13       
14       
15       
Schwab
Cell Formulas
RangeFormula
F9:F15F9=IF(ISTEXT($A9),VLOOKUP($A9,'All Tickers'!$H$11:$I$110,2,0),"")
G9:G15G9=IF(ISBLANK($A9),"",IF($F9=0,0,MAX($F9,$G9)))
H9:H15H9=IF(ISBLANK($A9),"",IF($H9=0,$F9,MEDIAN($H9,$F9,0)))
I9:I15I9=IF($A9="","",D9*E9)
J9:J15J9=IF($A9="","",$D9*$F9)
K9:K15K9=IF($A9="","",J9-I9)
L9:L10L9=IF($A9="","",($J9-$I9)/$I9)
L11:L15L11=IF($A11="","",K11/I11)
B9:B15B9=IF(COUNTIF(Sectors!$A$2:$AAJ$47,$A9)=1,INDEX(Sectors!$A$2:$AAJ$2,MAX((Sectors!$A$2:$AAJ$47=$A9)*(COLUMN(Sectors!$A$2:$AAJ$2)))),"")
Press CTRL+SHIFT+ENTER to enter array formulas.


Second Spreadsheet:
The Whole Enchilada.xlsm
ABCDEFGHIJKL
8 Symbol Sector Type Shares Price CURRENT MAX Value MIN Value CostMarket ValueGain/LossG/L %
9TECLTech 3XLong44$45.70$54.02$54.02$49.49$2,010.80$2,376.88$366.0818.21%
10TECLTech 3XLong21$45.80$54.02$54.02$49.49$961.80$1,134.42$172.6217.95%
11        
12        
13        
14        
15        
Roth IRA
Cell Formulas
RangeFormula
F9:F15F9=IF(ISTEXT($A9),VLOOKUP($A9,'All Tickers'!$H$11:$I$110,2,0),"")
G9:G15G9=IF(ISBLANK($A9),"",IF($F9=0,0,MAX($F9,$G9)))
H9:H15H9=IF(ISBLANK($A9),"",IF($H9=0,$F9,MEDIAN($H9,$F9,0)))
I9:I15I9=IF($A9="","",E9*D9)
J9:J15J9=IF($A9="","",$D9*$F9)
K9:K15K9=IF($A9="","",J9-I9)
L9:L15L9=IF($A9="","",K9/I9)
B9:B15B9=IF(COUNTIF(Sectors!$A$2:$AAJ$47,$A9)=1,INDEX(Sectors!$A$2:$AAJ$2,MAX((Sectors!$A$2:$AAJ$47=$A9)*(COLUMN(Sectors!$A$2:$AAJ$2)))),"")
Press CTRL+SHIFT+ENTER to enter array formulas.


Third Spreadsheet:
The Whole Enchilada.xlsm
ABCDEFGHIJKL
8 Symbol Sector Type Shares Cost CURRENT MAX Value MIN Value Cost ValueMarket ValueGain/LossG/L %
9CGFinanceLong25$34.30$31.95$31.95$30.00$857.50$798.75-$58.75-6.85%
10TECLTech 3XLong14$51.50$54.02$54.02$24.75$721.00$756.28$35.284.89%
11        
12        
13        
14        
15        
AMTD
Cell Formulas
RangeFormula
F9:F15F9=IF(ISTEXT($A9),VLOOKUP($A9,'All Tickers'!$H$11:$I$110,2,0),"")
G9:G15G9=IF(ISBLANK($A9),"",IF($F9=0,0,MAX($F9,$G9)))
H9:H15H9=IF(ISBLANK($A9),"",IF($H9=0,$F9,MEDIAN($H9,$F9,0)))
I9:I15I9=IF($A9="","",D9*E9)
J9:J15J9=IF($A9="","",$D9*$F9)
K9:K15K9=IF($A9="","",J9-I9)
L9:L15L9=IF($A9="","",K9/I9)
B9:B15B9=IF(COUNTIF(Sectors!$A$2:$AAJ$47,$A9)=1,INDEX(Sectors!$A$2:$AAJ$2,MAX((Sectors!$A$2:$AAJ$47=$A9)*(COLUMN(Sectors!$A$2:$AAJ$2)))),"")
Press CTRL+SHIFT+ENTER to enter array formulas.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Maybe
Excel Formula:
=AVERAGE(AVERAGEIFS(INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!L9:L15"),INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!A9:A15"),"TECL"))
 
Upvote 0
Solution
Maybe
Excel Formula:
=AVERAGE(AVERAGEIFS(INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!L9:L15"),INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!A9:A15"),"TECL"))
Perfect!
Thank you!
 
Upvote 0
Maybe
Excel Formula:
=AVERAGE(AVERAGEIFS(INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!L9:L15"),INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!A9:A15"),"TECL"))
It worked for the first symbol, but not the rest.
"TECL" is the only symbol listed more than once. Can we obtain average whether its listed once or multiple times?



The Whole Enchilada.xlsm
EF
38TECL36.98%
39TECL36.98%
40FAS#DIV/0!
41TSLL#DIV/0!
42TECL36.98%
43TECL36.98%
44CG#DIV/0!
45WBREOX#DIV/0!
46FBGKX#DIV/0!
Capital Gains Tax
Cell Formulas
RangeFormula
F41:F46,F38:F39F38=AVERAGE(AVERAGEIFS(INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!$L$9:$L$15"),INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!$A$9:$A$15"),E38))
F40F40=AVERAGE(AVERAGEIFS(INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!$L$9:$L$15"),INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!$A$9:$A$15"),"FAS"))
 
Upvote 0
Most likely, you are getting the #DIV/0! error not because of a symbol being listed just once, but because of the symbol being absent from or not having data on one or more sheets.

See if the following updated formula works for you:
Excel Formula:
=IFERROR(AVERAGE(IFERROR(AVERAGEIFS(INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!L9:L15"),INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!A9:A15"),E38),"")),"No Data")
Just a note: you don't need to use $L$9:$L$15 the INDIRECT function argument; just L9:L15 will work OK.
 
Upvote 0
Most likely, you are getting the #DIV/0! error not because of a symbol being listed just once, but because of the symbol being absent from or not having data on one or more sheets.

See if the following updated formula works for you:
Excel Formula:
=IFERROR(AVERAGE(IFERROR(AVERAGEIFS(INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!L9:L15"),INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!A9:A15"),E38),"")),"No Data")
Just a note: you don't need to use $L$9:$L$15 the INDIRECT function argument; just L9:L15 will work OK.
regarding: #DIV/0! error
there is data (L:L) regarding the lookup symbol, on a single spreadsheet (ie FAS, TSLL, CG).
i have the spreadsheets shown above.
some symbols are only listed once in on a single spreadsheet (ie FAS, TSLL, CG).

the second formula you replied with is only showing the G/L% from the first spreadsheet (Schwab).
I've add the IFERROR to the original formula (H:H).


The Whole Enchilada.xlsm
EFGH
34Average (L:L) for symbols in ALL spreadsheetsTest
35TECL36.98%91.23%36.98%
36FAS#DIV/0!16.40%No Data
37TSLL#DIV/0!0.44%No Data
38TECL36.98%91.23%36.98%
39TECL36.98%91.23%36.98%
40CG#DIV/0!No DataNo Data
Capital Gains Tax
Cell Formulas
RangeFormula
F35:F40F35=AVERAGE(AVERAGEIFS(INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!$L$9:$L$15"),INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!$A$9:$A$15"),E35))
G35:G40G35=IFERROR(AVERAGE(IFERROR(AVERAGEIFS(INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!L9:L15"),INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!A9:A15"),E35),"")),"No Data")
H35:H40H35=IFERROR(AVERAGE(AVERAGEIFS(INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!$L$9:$L$15"),INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!$A$9:$A$15"),E35)),"No Data")
 
Upvote 0
Most likely, you are getting the #DIV/0! error not because of a symbol being listed just once, but because of the symbol being absent from or not having data on one or more sheets.

See if the following updated formula works for you:
Excel Formula:
=IFERROR(AVERAGE(IFERROR(AVERAGEIFS(INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!L9:L15"),INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!A9:A15"),E38),"")),"No Data")
Just a note: you don't need to use $L$9:$L$15 the INDIRECT function argument; just L9:L15 will work OK.
I changed your formula to an array (G:G), now it works. Thank you.

Cell Formulas
RangeFormula
F35:F42F35=AVERAGE(AVERAGEIFS(INDIRECT("'"&"Schwab"&"'!$L$9:$L$15"),INDIRECT("'"&"Schwab"&"'!$A$9:$A$15"),E35),AVERAGEIFS(INDIRECT("'"&"Roth IRA"&"'!$L$9:$L$15"),INDIRECT("'"&"Roth IRA"&"'!$A$9:$A$15"),E35),AVERAGEIFS(INDIRECT("'"&"AMTD"&"'!$L$9:$L$15"),INDIRECT("'"&"AMTD"&"'!$A$9:$A$15"),E35))
G35:G42G35=IFERROR(AVERAGE(IFERROR(AVERAGEIFS(INDIRECT("'"&{"Schwab","Roth IRA","AMTD","401k"}&"'!L9:L15"),INDIRECT("'"&{"Schwab","Roth IRA","AMTD","401k"}&"'!A9:A15"),E35),"")),"No Data")
H35:H42H35=IFERROR(AVERAGE(AVERAGEIFS(INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!$L$9:$L$15"),INDIRECT("'"&{"Schwab","Roth IRA","AMTD"}&"'!$A$9:$A$15"),E35)),"No Data")
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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