+ Reply to Thread
Results 1 to 4 of 4

Calculating Averages Using VBA

  1. #1
    Registered User
    Join Date
    09-28-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    19

    Calculating Averages Using VBA

    I have a worksheet containing a list of measurements taken at 1 second intervals over the course of approximately 8 hours. Row A gives the time in hh:mm:ss, Row B contains the measurements.
    I would like to calculate the average value per minute, (i.e., the average of rows 1 – 60, 61 – 120, 121-180 etc… ) and output the result in a new table.

    As there are over 27000 rows in the worksheet, attempting to do this manually would take an age. I was hoping to use a macro to perform this task but having no VBA skills I don’t know where to start. Could anyone please point me in the right direction?

    I’ve made a rather poor attempt to put some pseudo code together for what I am trying to achieve…

    Please Login or Register  to view this content.
    Many thanks
    Stuart

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Calculating Averages Using VBA

    Given use of XL2007 I would suggest use a Pivot Table - this is purpose built for this type of analysis.

    Using your original table A:B as source (ensure you have titles for each column, eg Time / Value) you can set the PT up such that

    ROW Label: Time
    DATA Field: Value -- set to AVERAGE (rather than SUM)

    Right click on any Time value in the PT and choose GROUP and select HOURS & MINUTES (nothing else).... with the PT active you can alter the layout/design of the PT to be however you wish using the options provided via the Ribbon (Design)

  3. #3
    Registered User
    Join Date
    09-28-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Calculating Averages Using VBA

    Thats great, thanks for the quick reply. I was overcomplicating the issue somewhat wasn't I?
    Thanks again!

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Calculating Averages Using VBA

    No problem - never underestimate the power of the Pivot Table !

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1