View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Matthew Dyer Matthew Dyer is offline
external usenet poster
 
Posts: 178
Default 2 dimensional loop, averageif formula

On Mar 23, 11:31*pm, Javed wrote:
Hope the following will solve the problem

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


so here's what i've got to get "c" to advance, but as you may
understand ii is returning an integer instead of a text charachter
(i.e 3 instead of c, 4 instead of d, etc.)

Cells(i, ii).Formula = "=averageif(a1:a" & LastRw & ",b" & i &
"," & ii & "1:" & ii & LastRw & ")"

i've declared a new variable avgcol to be put in place of ii as
follows:

Cells(i, ii).Formula = "=averageif(a1:a" & LastRw & ",b" & i &
"," & avgcol & "1:" & avgcol & LastRw & ")"

but how do i turn 3 into c, 4 into d.... 27 into aa... etc?