Try this code. It assumes the header row in in row 1 and the column A has no
blank cells from row 2 to the end.
Sub Gettotals()
'
'
'
RowCount = 2
Start = 2
Do While Range("A" & RowCount) < ""
If Range("A" & RowCount) < Range("A" & (RowCount + 1)) Then
Rows(RowCount + 1).Insert
Range("B" & (RowCount + 1)).Formula = _
"=Sum(B" & Start & ":B" & RowCount & ")"
Set SetSumRange = _
Range("B" & (RowCount + 1) & ":U" & (RowCount + 1))
Range("B" & (RowCount + 1)).Copy _
Destination:=SetSumRange
With SetSumRange.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
RowCount = RowCount + 2
Start = RowCount
Else
RowCount = RowCount + 1
End If
Loop
End Sub
"Sverre" wrote:
I have a large daatasheet with integer. After each group of data the average
is calculated and the results are introduced as decimals which starts from
column B to U.
I do want to have a yellow backgrund colour from A to U in this row with
the averages. How can I do that in VB.