Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro code please
Some help please. upon the running of a macro I would like to be able to
display in a message box the sum of numbers in the seven cells above the active cell and also the average of the sum of the same cells that contain a number greater than zero. TIA Neal |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
vba/macro code | New Users to Excel | |||
VBA code for macro help | Excel Discussion (Misc queries) | |||
Deleting code from a macro (by a macro) | Excel Discussion (Misc queries) | |||
Excel XP VBA code to search all macro code in Excel module for specific search string criteria | Excel Programming | |||
Excel XP VBA code to search all macro code in Excel module for specific search string criteria | Excel Programming |