M
Matt S
All,
I'm sort of a neat freak. In the following code, I am simply trying to take
the average of three arrays arrTop, arrMiddle, and arrBottom. They have
differing lengths, but always 11 columns. Is there a simpler way to do this?
Something that looks a little cleaner?
THANKS SO MUCH!
Matt
'Take average of data
ReDim arrAvTop(1 To 11)
ReDim arrAvMiddle(1 To 11)
ReDim arrAvBottom(1 To 11)
Sum1 = 0
Sum2 = 0
Sum3 = 0
Sum4 = 0
Sum5 = 0
Sum6 = 0
Sum7 = 0
Sum8 = 0
Sum9 = 0
Sum10 = 0
Sum11 = 0
For j = 1 To 11
For k = 1 To UBound(arrTop)
Sum1 = Sum1 + arrTop(j, k)
Sum2 = Sum2 + arrTop(j, k)
Sum3 = Sum3 + arrTop(j, k)
Sum4 = Sum4 + arrTop(j, k)
Sum5 = Sum5 + arrTop(j, k)
Sum6 = Sum6 + arrTop(j, k)
Sum7 = Sum7 + arrTop(j, k)
Sum8 = Sum8 + arrTop(j, k)
Sum9 = Sum9 + arrTop(j, k)
Sum10 = Sum10 + arrTop(j, k)
Sum11 = Sum11 + arrTop(j, k)
arrAvTop(1) = Sum1 / k
arrAvTop(2) = Sum2 / k
arrAvTop(3) = Sum3 / k
arrAvTop(4) = Sum4 / k
arrAvTop(5) = Sum5 / k
arrAvTop(6) = Sum6 / k
arrAvTop(7) = Sum7 / k
arrAvTop(8) = Sum8 / k
arrAvTop(9) = Sum9 / k
arrAvTop(10) = Sum10 / k
arrAvTop(11) = Sum11 / k
Next k
Sum1 = 0
Sum2 = 0
Sum3 = 0
Sum4 = 0
Sum5 = 0
Sum6 = 0
Sum7 = 0
Sum8 = 0
Sum9 = 0
Sum10 = 0
Sum11 = 0
For k = 1 To UBound(arrMiddle)
Sum1 = Sum1 + arrMiddle(j, k)
Sum2 = Sum2 + arrMiddle(j, k)
Sum3 = Sum3 + arrMiddle(j, k)
Sum4 = Sum4 + arrMiddle(j, k)
Sum5 = Sum5 + arrMiddle(j, k)
Sum6 = Sum6 + arrMiddle(j, k)
Sum7 = Sum7 + arrMiddle(j, k)
Sum8 = Sum8 + arrMiddle(j, k)
Sum9 = Sum9 + arrMiddle(j, k)
Sum10 = Sum10 + arrMiddle(j, k)
Sum11 = Sum11 + arrMiddle(j, k)
arrAvMiddle(1) = Sum1 / k
arrAvMiddle(2) = Sum2 / k
arrAvMiddle(3) = Sum3 / k
arrAvMiddle(4) = Sum4 / k
arrAvMiddle(5) = Sum5 / k
arrAvMiddle(6) = Sum6 / k
arrAvMiddle(7) = Sum7 / k
arrAvMiddle(8) = Sum8 / k
arrAvMiddle(9) = Sum9 / k
arrAvMiddle(10) = Sum10 / k
arrAvMiddle(11) = Sum11 / k
Next k
Sum1 = 0
Sum2 = 0
Sum3 = 0
Sum4 = 0
Sum5 = 0
Sum6 = 0
Sum7 = 0
Sum8 = 0
Sum9 = 0
Sum10 = 0
Sum11 = 0
For k = 1 To UBound(arrTop)
Sum1 = Sum1 + arrTop(j, k)
Sum2 = Sum2 + arrTop(j, k)
Sum3 = Sum3 + arrTop(j, k)
Sum4 = Sum4 + arrTop(j, k)
Sum5 = Sum5 + arrTop(j, k)
Sum6 = Sum6 + arrTop(j, k)
Sum7 = Sum7 + arrTop(j, k)
Sum8 = Sum8 + arrTop(j, k)
Sum9 = Sum9 + arrTop(j, k)
Sum10 = Sum10 + arrTop(j, k)
Sum11 = Sum11 + arrTop(j, k)
arrAvTop(1) = Sum1 / k
arrAvTop(2) = Sum2 / k
arrAvTop(3) = Sum3 / k
arrAvTop(4) = Sum4 / k
arrAvTop(5) = Sum5 / k
arrAvTop(6) = Sum6 / k
arrAvTop(7) = Sum7 / k
arrAvTop(8) = Sum8 / k
arrAvTop(9) = Sum9 / k
arrAvTop(10) = Sum10 / k
arrAvTop(11) = Sum11 / k
Next k
Next j
I'm sort of a neat freak. In the following code, I am simply trying to take
the average of three arrays arrTop, arrMiddle, and arrBottom. They have
differing lengths, but always 11 columns. Is there a simpler way to do this?
Something that looks a little cleaner?
THANKS SO MUCH!
Matt
'Take average of data
ReDim arrAvTop(1 To 11)
ReDim arrAvMiddle(1 To 11)
ReDim arrAvBottom(1 To 11)
Sum1 = 0
Sum2 = 0
Sum3 = 0
Sum4 = 0
Sum5 = 0
Sum6 = 0
Sum7 = 0
Sum8 = 0
Sum9 = 0
Sum10 = 0
Sum11 = 0
For j = 1 To 11
For k = 1 To UBound(arrTop)
Sum1 = Sum1 + arrTop(j, k)
Sum2 = Sum2 + arrTop(j, k)
Sum3 = Sum3 + arrTop(j, k)
Sum4 = Sum4 + arrTop(j, k)
Sum5 = Sum5 + arrTop(j, k)
Sum6 = Sum6 + arrTop(j, k)
Sum7 = Sum7 + arrTop(j, k)
Sum8 = Sum8 + arrTop(j, k)
Sum9 = Sum9 + arrTop(j, k)
Sum10 = Sum10 + arrTop(j, k)
Sum11 = Sum11 + arrTop(j, k)
arrAvTop(1) = Sum1 / k
arrAvTop(2) = Sum2 / k
arrAvTop(3) = Sum3 / k
arrAvTop(4) = Sum4 / k
arrAvTop(5) = Sum5 / k
arrAvTop(6) = Sum6 / k
arrAvTop(7) = Sum7 / k
arrAvTop(8) = Sum8 / k
arrAvTop(9) = Sum9 / k
arrAvTop(10) = Sum10 / k
arrAvTop(11) = Sum11 / k
Next k
Sum1 = 0
Sum2 = 0
Sum3 = 0
Sum4 = 0
Sum5 = 0
Sum6 = 0
Sum7 = 0
Sum8 = 0
Sum9 = 0
Sum10 = 0
Sum11 = 0
For k = 1 To UBound(arrMiddle)
Sum1 = Sum1 + arrMiddle(j, k)
Sum2 = Sum2 + arrMiddle(j, k)
Sum3 = Sum3 + arrMiddle(j, k)
Sum4 = Sum4 + arrMiddle(j, k)
Sum5 = Sum5 + arrMiddle(j, k)
Sum6 = Sum6 + arrMiddle(j, k)
Sum7 = Sum7 + arrMiddle(j, k)
Sum8 = Sum8 + arrMiddle(j, k)
Sum9 = Sum9 + arrMiddle(j, k)
Sum10 = Sum10 + arrMiddle(j, k)
Sum11 = Sum11 + arrMiddle(j, k)
arrAvMiddle(1) = Sum1 / k
arrAvMiddle(2) = Sum2 / k
arrAvMiddle(3) = Sum3 / k
arrAvMiddle(4) = Sum4 / k
arrAvMiddle(5) = Sum5 / k
arrAvMiddle(6) = Sum6 / k
arrAvMiddle(7) = Sum7 / k
arrAvMiddle(8) = Sum8 / k
arrAvMiddle(9) = Sum9 / k
arrAvMiddle(10) = Sum10 / k
arrAvMiddle(11) = Sum11 / k
Next k
Sum1 = 0
Sum2 = 0
Sum3 = 0
Sum4 = 0
Sum5 = 0
Sum6 = 0
Sum7 = 0
Sum8 = 0
Sum9 = 0
Sum10 = 0
Sum11 = 0
For k = 1 To UBound(arrTop)
Sum1 = Sum1 + arrTop(j, k)
Sum2 = Sum2 + arrTop(j, k)
Sum3 = Sum3 + arrTop(j, k)
Sum4 = Sum4 + arrTop(j, k)
Sum5 = Sum5 + arrTop(j, k)
Sum6 = Sum6 + arrTop(j, k)
Sum7 = Sum7 + arrTop(j, k)
Sum8 = Sum8 + arrTop(j, k)
Sum9 = Sum9 + arrTop(j, k)
Sum10 = Sum10 + arrTop(j, k)
Sum11 = Sum11 + arrTop(j, k)
arrAvTop(1) = Sum1 / k
arrAvTop(2) = Sum2 / k
arrAvTop(3) = Sum3 / k
arrAvTop(4) = Sum4 / k
arrAvTop(5) = Sum5 / k
arrAvTop(6) = Sum6 / k
arrAvTop(7) = Sum7 / k
arrAvTop(8) = Sum8 / k
arrAvTop(9) = Sum9 / k
arrAvTop(10) = Sum10 / k
arrAvTop(11) = Sum11 / k
Next k
Next j