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
|