View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default summing dynamic ranges

I should have added that this assumes that your data is constants only, not values from formulas.

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Alan,

Loop through the areas:

Sub TryNow()
Dim myArea As Range
For Each myArea In Range("O:O").SpecialCells(xlCellTypeConstants).Are as
With myArea.Cells(myArea.Cells.Count + 1)
.Formula = "=AVERAGE(" & myArea.Address & ")"
.Font.Bold = True
End With
Next myArea
End Sub

HTH,
Bernie
MS Excel MVP


"Alan M" wrote in message
...
Hi there

I have column of data in blocks of consecutive cells. There are a varying
number of rows containing data and varying number of blank rows between the
data.

I have used the following code to set the average for the last block of data
in the column....

Dim rgSumRange As Range
Dim rgAverage As Range



Cells(Rows.Count, "o").End(xlUp).Offset(0, 0).Select

Set rgSumRange = ActiveCell.CurrentRegion.Columns(15)
Set rgAverage = rgSumRange.Rows(rgSumRange.Rows.Count + 1)

rgAverage.Formula = "=Average(" & rgSumRange.Columns(1).Address(True, False)
& ")"

rgAverage.Font.Bold = True

I need to navigate up the sheet past the empty ros to the next block of data.

How do I do that please?