Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
vba/macro code JSHARP92 New Users to Excel 0 March 6th 11 03:06 PM
VBA code for macro help Cam Excel Discussion (Misc queries) 0 September 7th 07 07:14 PM
Deleting code from a macro (by a macro) Brettjg Excel Discussion (Misc queries) 2 May 8th 07 10:14 PM
Excel XP VBA code to search all macro code in Excel module for specific search string criteria Ed[_18_] Excel Programming 4 May 20th 04 02:08 PM
Excel XP VBA code to search all macro code in Excel module for specific search string criteria Frank Kabel Excel Programming 0 May 19th 04 08:11 PM


All times are GMT +1. The time now is 03:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"