View Single Post
  #4   Report Post  
Diederik
 
Posts: n/a
Default

"rae820" wrote:


There is a way...if you go to insert--function, the category dropdown
box and look at statistical. then you get all sorts of functions you
are looking for...
=average(c1:c23)
=stdev(c1:c23)... for example


--
rae820
------------------------------------------------------------------------


It is too many clicks away before I get the function. I have now found a vb
workaround that des the trick for me. The code is as follows:

Sub VariableAverage()

Dim strFrom As String
Dim strTo As String

strFrom = ActiveCell.Offset(-1, 0).Row
If strFrom = "" Then Exit Sub
strTo = ActiveCell.Offset(-1, 0).End(xlUp).Row
If strTo = "" Then Exit Sub

ActiveCell.FormulaR1C1 = "=average(R" & strFrom & "C:R" & strTo & "C)"

End Sub