Formula to calculate the average and sum of a range with criteria

bezbid

New Member
Joined
Nov 27, 2016
Messages
21
Office Version
  1. 365
  2. 2016
  3. 2010
  4. 2007
Book1
ABCDEFGHI
1115100 14.44Sumproduct/Sum (average) if D="o"
2230200 
339100o211,600Sum of C1:C20 where D="o"1,800
4420400o20.5
5510100o19.3
6610200o17.6
7725100o18.3
8810300o16.6
9930100o17.4
10109300o16.1
111140100 
12128.5100 
131310.5100 
141410200 
151535100 
16169.5200 
17179500 
181825100 
191910.5100 
202010200 
21
Sheet2
Cell Formulas
RangeFormula
F1F1=IF(SUM(E1:E20)<=0,"",ROUND(SUMPRODUCT((INDEX($B1:$B20,MATCH("*",$D1:$D20,0)-0,0):INDEX($B1:$B20,MATCH("*",$D1:$D20,-1)-0,0)),(INDEX($C1:$C20,MATCH("*",$D1:$D20,0)-0,0):INDEX($C1:$C20,MATCH("*",$D1:$D20,-1)-0,0)))/SUM(INDEX($C1:$C20,MATCH("*",$D1:$D20,0)-0,0):INDEX($C1:$C20,MATCH("*",$D1:$D20,-1)-0,0)),2))
F3F3=IFERROR(IF(SUM(E1:E20)<=0,"",SUM(INDEX($C1:$C20,MATCH("*",$D1:$D20,0)-0,0):(INDEX($C1:$C20,MATCH("*",$D1:$D20,-1)-0,0)))),"")
E1:E20E1=IFERROR(IF($D1<>"o","",ROUND(SUMPRODUCT(B$1:B1,C$1:C1)/SUM(C$1:C1),1)),"")


the formula in F1 and F3 works fine with the "o" in continuous cells, but what is i want the calculation for it if the "o" is in following,

Book1
ABCDEFGHIJ
1115100 15.13Sumproduct/Sum (average) if D="o"1
2230200o25
339100 3,100Sum of C1:C20 where D="o"1,800
4420400 
5510100o19.3
6610200o17.6
7725100 
8810300 
9930100 
10109300o16.1
111140100o17.3
12128.5100 
131310.5100o16.6
141410200 
151535100o16.8
16169.5200o16.3
17179500o15.1
181825100 
191910.5100 
202010200 
21
Sheet1
Cell Formulas
RangeFormula
F1F1=IF(SUM(E1:E20)<=0,"",ROUND(SUMPRODUCT((INDEX($B1:$B20,MATCH("*",$D1:$D20,0)-0,0):INDEX($B1:$B20,MATCH("*",$D1:$D20,-1)-0,0)),(INDEX($C1:$C20,MATCH("*",$D1:$D20,0)-0,0):INDEX($C1:$C20,MATCH("*",$D1:$D20,-1)-0,0)))/SUM(INDEX($C1:$C20,MATCH("*",$D1:$D20,0)-0,0):INDEX($C1:$C20,MATCH("*",$D1:$D20,-1)-0,0)),2))
F3F3=IFERROR(IF(SUM(E1:E20)<=0,"",SUM(INDEX($C1:$C20,MATCH("*",$D1:$D20,0)-0,0):(INDEX($C1:$C20,MATCH("*",$D1:$D20,-1)-0,0)))),"")
E1:E20E1=IFERROR(IF($D1<>"o","",ROUND(SUMPRODUCT(B$1:B1,C$1:C1)/SUM(C$1:C1),1)),"")
 
Last edited:

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
please help me if the formula in F1 and F3 can be simplified, thanks in advance
 
Upvote 0
An explanation of the calculation that you require would help.
SumProduct 2022a.xlsm
ABCDEF
1115100 14.4375
2230200 
339100o211,600.00
4420400o20.5
5510100o19.3
6610200o17.6
7725100o18.3
8810300o16.6
9930100o17.4
10109300o16.1
111140100 
12128.5100 
131310.5100 
141410200 
151535100 
16169.5200 
17179500 
181825100 
191910.5100 
202010200 
5b
Cell Formulas
RangeFormula
F1F1=SUMPRODUCT(--(D1:D20>""),B1:B20,C1:C20)/F3
F3F3=SUM(($D1:$D20="o")*C1:C20)
E1:E20E1=IFERROR(IF($D1<>"o","",ROUND(SUMPRODUCT(B$1:B1,C$1:C1)/SUM(C$1:C1),1)),"")


?? expected results are?
SumProduct 2022a.xlsm
ABCDEFG
1115100 14.81
2230200o25
339100 1,800.00
4420400 
5510100o19.3
6610200o17.6
7725100 
8810300 
9930100 
10109300o16.1
111140100o17.3
12128.5100 
131310.5100o16.6
141410200 
151535100o16.8
16169.5200o16.3
17179500o15.1
181825100 
191910.5100 
202010200 
5bb
Cell Formulas
RangeFormula
F1F1=SUMPRODUCT(--(D1:D20>""),B1:B20,C1:C20)/F3
F3F3=SUM(($D1:$D20="o")*C1:C20)
E1:E20E1=IFERROR(IF($D1<>"o","",ROUND(SUMPRODUCT(B$1:B1,C$1:C1)/SUM(C$1:C1),1)),"")
 
Last edited:
Upvote 0
SumProduct 2022a.xlsm
BCDEF
115100 14.81
230200o25
39100 1,800.00
420400 
510100o19.3
610200o17.6
725100 
810300 
930100 
109300o16.1
1140100o17.3
128.5100 
1310.5100o16.6
1410200 
1535100o16.8
169.5200o16.3
179500o15.1
1825100 
1910.5100 
2010200 
5bb
Cell Formulas
RangeFormula
F1F1=SUM((D1:D20>"")*B1:B20*C1:C20)/F3
F3F3=SUM(($D1:$D20="o")*C1:C20)
E1:E20E1=IFERROR(IF($D1<>"o","",ROUND(SUMPRODUCT(B$1:B1,C$1:C1)/SUM(C$1:C1),1)),"")
 
Upvote 0
Solution
SumProduct 2022a.xlsm
BCDEF
11510014.81
230200o
391001,800.00
420400
510100o
610200o
725100
810300
930100
109300o
1140100o
128.5100
1310.5100o
1410200
1535100o
169.5200o
179500o
1825100
1910.5100
2010200
5bb
Cell Formulas
RangeFormula
F1F1=SUM((D1:D20>"")*B1:B20*C1:C20)/F3
F3F3=SUM(($D1:$D20="o")*C1:C20)
 
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