View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip[_3_] Chip[_3_] is offline
external usenet poster
 
Posts: 133
Default Macro code please

Here you go.

Sub last7()

sumtotal = 0
countofaverages = 0
averagetotal = 0

For i = 1 To 7
sumtotal = ActiveCell.Offset(-i, currentcolumn).Value + sumtotal

If ActiveCell.Offset(-i, currentcolumn).Value 0 Then
averagetotal = ActiveCell.Offset(-i, currentcolumn).Value +
averagetotal
countofaverages = 1 + countofaverages
End If

Next i
MsgBox "Sum: " & sumtotal
t = averagetotal / countofaverages
MsgBox "Average: " & t
End Sub