View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Matt R Matt R is offline
external usenet poster
 
Posts: 2
Default Averaging Random Selections?

It took a while but was able to piece other pieces of code together to get to
it. Here it is......i'm sure just one of many possible solutions

Sub average()

Dim i As Long
Dim j As Long
Dim start As Long


i = ActiveCell.Row - 1
start = i

j = ActiveCell.Column

If Cells(i, j).Value = "" Then
Exit Sub
End If

Do While Cells(i, j).Value < ""

i = i - 1

Loop

i = i + 1

Selection.Formula = "=average(" & Cells(i, j).Address & ":" & Cells(start,
j).Address & ")"

End Sub





"Matt R" wrote:

Hi,

Need the syntax to calculate the average of a range of cells and it will
know where to stop the range when it finds a blank cell.
Selection.Formula.....etc... (e.g. Just how the Sum (Sigma) function works
already)

Thanks for your help

Matt R