VB Excel Macro code for computing averages - need help

Author Message
deppe.k

  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 12/11/2009
  • Status: offline
VB Excel Macro code for computing averages - need help Friday, December 11, 2009 8:34 AM (permalink)
0
I use LabView software and when I run a test in the lab, all the data is dumped into excel through a macro that organizes it. Usually I have rows of data and the macro, at the end, computes the average of the last 10 values per column. However, the problem is that if there isn't 10 rows of data, it spits out an error. What I want is for it to still compute the average even if there are 9 or less values(rows). Any help is appreciated.

This is what I have so far. Like I said, it computes the average of the last 10 values per column:

'Start of Average Macro

   Cells.Find(What:="timestamp", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False).Activate
       
    ActiveCell.Offset(0, 1).Select
    Selection.End(xlDown).Select
       
       
    Do
       
        Selection.Range("A3").Select
        ActiveCell.FormulaR1C1 = "=AVERAGE(R[-11]C:R[-2]C)"
        ActiveCell.Offset(-2, 1).Select
       
       
    Loop While Abs(ActiveCell) > 0.05
 
#1

    Online Bookmarks Sharing: Share/Bookmark

    Jump to:

    Current active users

    There are 0 members and 1 guests.

    Icon Legend and Permission

    • New Messages
    • No New Messages
    • Hot Topic w/ New Messages
    • Hot Topic w/o New Messages
    • Locked w/ New Messages
    • Locked w/o New Messages
    • Read Message
    • Post New Thread
    • Reply to message
    • Post New Poll
    • Submit Vote
    • Post reward post
    • Delete my own posts
    • Delete my own threads
    • Rate post

    2000-2012 ASPPlayground.NET Forum Version 3.9