ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Averaging Random Selections? (https://www.excelbanter.com/excel-programming/345659-re-averaging-random-selections.html)

Matt R

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



All times are GMT +1. The time now is 10:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com