I have an Excel document consisting of 12 sheets.
Every sheet contains a lot of data, ranging from column A to X and with a variable range in rows.
I'm trying to calculate the mean and the Standard error of every column, for every sheet. Preferably with an output on a summary sheet.
My thinking process:
- I managed to let every cell under the last row calculate the average.
- When I tried to do the same with the standard error, the problem is that the average calculated in step 1) was included in the calculations.
- After all, it seems more convenient to display the results of these calculations in a separate 'summary' tab.
Here's the code I tried, which works for the averages to be produced right below the last value in the columns.
Sub ColumnAverageFormula()
For i = 3 To 24
Columns(Columns(i).Address).Select
Cells(1, ActiveCell.Column).End(xlDown).Offset(1, 0).Formula = "=Average(" & Cells(1, ActiveCell.Column).Address(0, 0) & ":" & Cells(1, ActiveCell.Column).End(xlDown).Address(0, 0) & ")"
Next i
For j = 3 To 24
Columns(Columns(j).Address).Select
Cells(1, ActiveCell.Column).End(xlDown).Offset(1, 0).Formula = "=stdev.p(" & Cells(1, ActiveCell.Column).Address(0, 0) & ":" & Cells(1, ActiveCell.Column).End(xlDown).Address(0, 0) & ")"
Next j
End Sub
Tl;dr: I'd like to write code that calculates the average and the standard error of every column of every sheet in my Excel file, and the results should be produced on a 'summary' sheet.
Table. - PatricK