View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.programming
Markus Scheible[_2_] Markus Scheible[_2_] is offline
external usenet poster
 
Posts: 95
Default How to calculate this on all rows?

Hi Albert,


By the way, I'd like the sub:

Sub dropdown()
For i = 2 To 2976 '35562
Range("I" & i).Formula = "=Average(F" & i & ":g" & i

& ":h" & i & ")"
Next i
End Sub



....To stop whenever ("A" & i) is empty.
You probably have the code in your mind right now. :P


..Range("A1", "A65532").SpecialCells(xlCellTypeBlanks).Cells
(1).Row

gives you the first empty cell as a number, you could use
this as the max for i like:


Sub dropdown()

For i = 2 To (Range("A1", "A65532").SpecialCells
(xlCellTypeBlanks).Cells
(1).Row - 1)

Range("I" & i).Formula = "=Average(F" & i & ":g" & i
& ":h" & i & ")"

Next i

End Sub

But I personally would prefer Bobs method because its
shorter and I think it is faster to run, like it follows:


i = Range("A1", "A65532").SpecialCells
(xlCellTypeBlanks).Cells
(1).Row - 1)

With Range("E2")
..Formula = "=GEMIDDELDE(F2:H2)"
..AutoFill Destination:=Range("E2:E" & i),
Type:=xlFillDefault
End With

BTW: Your homepage is really content-overloaded ;o)

Have a nice day!

Markus



Ps, Markus, most Dutch words sound like the German

ones. ;)



Ich weiß ;o) My boss is from the Netherlands...






"Bob Phillips"

schreef in bericht
...
Thanks Albert, that confirms what I had been told (I

have an English
version, so cannot check). It's kinda neat that Excel

translates it though
:-)

BTW, to get the English version, you can type the local

name in a cell as
a
proper formula, and then in the VB IDE, type this in

the immediate window
?activecell.formula
and it gives you the English

Bob



.