View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
joeu2004 joeu2004 is offline
external usenet poster
 
Posts: 2,059
Default 2 dimensional loop, averageif formula

On Mar 23, 5:54*pm, joeu2004 wrote:
On Mar 23, 4:27*pm, Matthew Dyer wrote:
For i = LastRw + 2 To LastRw + 4
* * For ii = LastCol - 37 To LastCol
* * Cells(i, ii).Formula = "=averageif(a1:a" & lastrw & ",b" &i&
",c1:c" &lastcol& ")"
* * Next ii
Next i

[....]
It also seems odd to me that the only thing that will change
in your AVERAGEIF is i. *My guess is that you also want to
"b" to vary with ii.


Probably a bad guess. Let me rephrase....

I seems odd to me that you want to fill each row with 38 formulas all
of which look the same in that row, to wit for the kth row:

=AVERAGEIF(A1:An,Bk,C1:Cm)

where n is invariant (lastrow), m is invariant (lastcol) and k is
invariant within the row (k = lastrow+2, lastrow+3 or lastrow+4).