Quickly doing averages over multiple columns and rows.

Monty_Droppings

New Member
Joined
Oct 1, 2014
Messages
2
Hello, I have data 3 columns wide and I am trying to take the average of all 3 columns together in groups of 12 rows.

Is there a way I can do this without having to click manually as I have several thousand data points.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Easy
Code:
Function myAverage(myRange)
     Application.Volatile
     For Each Cell in myRange
          myTotal = myTotal + myRange
          counter = counter + 1
     Next Cell
myAverage = myTotal / counter
End Function
In whatever cell you want the output to go, type this formula
=myAverage(A1:C12)
I'm assuming of course that your first 12 rows are in column A through C.
 
Last edited:
Upvote 0
And if that doesn't work, try changing the first line to this
Function myAverage(myRange As Excel.Range)
 
Upvote 0
Here's one way with a formula, may be better ways. Assumes data staring in row 1, columns A to C:

First formula:

=AVERAGE(INDEX($A$1:$C$36,1,3):INDEX($A$1:$C$36,12,3))

Second formula and copy down, change the range for your data:

=AVERAGE(INDEX($A$1:$C$36,1+(ROWS($A$1:A1)*12),3):INDEX($A$1:$C$36,ROWS($A$1:A2)*12,3))
 
Upvote 0
Welcome to the MrExcel board!

Here's another way. I've done it in groups of 4 rows, not 12. You should be able to adapt to 12 but if not post back & I will elaborate.

Formula in D2 is copied down.


Excel Workbook
ABCD
1
27564.91667
3337
4178
5714
68845.83333
7981
8945
9716
105365.75
11633
12886
13993
147934.83333
15519
16716
17118
186565.5
19943
20
21
Average Rows
 
Upvote 0
.. or if you don't want the averages spread out like that, here's another possibility, similar to Joyner's suggestion.

Excel Workbook
ABCD
1
27564.91667
33375.83333
41785.75
57144.83333
68845.5
7981
8945
9716
10536
11633
12886
13993
14793
15519
16716
17118
18656
19943
20
21
Average Rows
 
Upvote 0
Hello Peter, thanks for fixing the code to work in all cells, I was too tired last night and I could not quite get the first part of the index to work on the first row. Also, I realize my use of the entire range is unnecessary, just the first and last column as you have it.

Thanks
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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