Sub ar2()
Dim i As Long, a As Long, b As Long
Dim co As Long, ae As Integer
For colno = 2 To 7
a = 0
For i = 2 To 13
a = a + Cells(i, colno).Value
Next i
b = 0
For co = 2 To Cells(Rows.count, colno).End(xlUp).Row
b = b + 1
Next co
Range(Cells(3, 8 + colno), Cells(3, 8 + colno)).Value = b '###COUNT
Cells(2, 8 + colno).Value = a '####SUM
ae = a / b
Range(Cells(4, 8 + colno), Cells(4, 8 + colno)).Value = ae '###AVERAGE
Next colno
End Sub
Sub ar2()
Dim i As Long, a As Long, b As Long
Dim colno As Long, lr as Integer
For colno = 3 To 7
a = 0
b = 0
lr = Cells(Rows.Count, colno).End(xlUp).Row
For i = 2 To lr
a = a + Cells(i, colno).Value
If Cells(i, colno).Value <> "" Then b = b + 1
Next i
Cells(3, 9 + colno) = a 'SUM
Cells(4, 9 + colno) = b 'COUNT
Cells(5, 9 + colno) = a / b 'AVERAGE
Next colno
End Sub
Sub ar2()
Dim i As Long, a As Long, b As Long
Dim co As Long, ae As Integer
For colno = 2 To 7
a = 0
b = 0
For i = 2 To 13
a = a + Cells(i, colno).Value
b = b + 1
Next i
Range(Cells(3, 8 + colno), Cells(3, 8 + colno)).Value = b '###COUNT
Cells(2, 8 + colno).Value = a '####SUM
ae = a / b
Range(Cells(4, 8 + colno), Cells(4, 8 + colno)).Value = ae '###AVERAGE
Next colno
End Sub
Sub See_What_Happens()
Dim i As Long, j As Long, x As Long
x = 0
For i = 1 To 5
For j = 1 To 6
Cells(j, i).Value = x + 1
x = x + 1
MsgBox "Do you see what happened?"
Next j
Next i
End Sub
as long the code cover all thedynamicarray 12 by 12
Sub Demo0()
Dim V(), A(), C%, R&, F&, W()
V = [{"sum","count","average"}]
Columns("I:R").Clear
With Me.UsedRange.Columns
ReDim A(3, .Count)
For C = 1 To .Count: A(0, C) = Split(.Cells(C).Address, "$")(1): Next
For R = 1 To 3: A(R, 0) = V(R): Next
V = .Value2
End With
For F = 1 To UBound(V) - 11
W = A: W(0, 0) = "#" & F
For R = F To F + 11
For C = 1 To C - 1
If V(R, C) Then W(1, C) = W(1, C) + V(R, C): W(2, C) = W(2, C) + 1
Next C, R
For C = 1 To C - 1
If W(2, C) Then W(3, C) = W(1, C) / W(2, C)
Next
With Cells(F + (F - 1) * 4, 10).Resize(4, C)
.NumberFormat = "#,##0_W;;0_W;_y@"
.Value2 = W
End With
Next
End Sub
I avoid to use any function or formula because I want to see how the loop really work
I found out there are not theory how to repeat the whole code