VBA to take averages of a group of cells in a column based on true/false criteria

Pcool

Board Regular
Joined
Nov 28, 2011
Messages
69
I want to be able to take the average of grouped(based on the "true" in the B column) values(taken from the numbers in the A column) that will be displayed in the C column.
Does anyone know how to automate this using VBA or a formula?

A1
Amount
B1
True/False
C1
Average
5False0
3False0
8True=AVERAGE(A4:A10)
3True
2True
8True
6True
7True
4True
5False0
1False0
2False0
3True
4True
8False
9True
6False
3True
2True

<tbody>
</tbody>
 
Last edited:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
what's the criteria for average? How do you know which values do you have put in the average formula?
 
Upvote 0
what's the criteria for average? How do you know which values do you have put in the average formula?

Sorry about that, If it is "True" in Column B, then take the value from column A. I guess the real challenge is dynamically collecting groups in column A.

So in my above example A4:A10, A14:A15, A17, A18:A19 would be different groups resulting in 5.42, 3.5, 9, and 2.5 in column C
 
Upvote 0
Can I bump this?
I want the end result to be like this
1A1
Amount
B1
True/False
C1
Average
25False0
33False0
48True=AVERAGE(A4:A10)
53True=AVERAGE(A4:A10)
62True=AVERAGE(A4:A10)
78True=AVERAGE(A4:A10)
86True=AVERAGE(A4:A10)
97True=AVERAGE(A4:A10)
104True=AVERAGE(A4:A10)
115False0
121False0
132False0
143True=AVERAGE(A14:A15)
154True=AVERAGE(A14:A15)
168False0
179True=AVERAGE(A17)
186False0
193True=AVERAGE(A19:A20)
202True=AVERAGE(A19:A20)

<tbody>
</tbody>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,874
Members
449,056
Latest member
ruhulaminappu

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