+ Reply to Thread
Results 1 to 2 of 2

Averaging a range with missing values

  1. #1
    Registered User
    Join Date
    07-13-2011
    Location
    Glasgow
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    21

    Averaging a range with missing values

    Hi there

    I was looking for some help

    I have a long data range which consists of solar radiation measurements .To this data i am averaging every 5 readings (i.e. taking 5 minute averages of my data). To do this I am using the code attached below.

    Please Login or Register  to view this content.
    However the problem I have come up against is that some of the data is missing thus it is putting my averages off slightly by the end.

    Besides the column with the measurements I have columns with the hour and minute the value was recorded.

    I was wondering if any of you had an idea of how to set the VBA code attached to see if the values are between a range and then average they values.

    For example if my solar radiation is in column F and the minute it was recorded is in column E I would like the code to look at the minute value and average all the values in column F when minute is between a range of 5( i.e.between 0 to 4 , then 5 to 9 minutes and so on)all the way up to 59minutes then start again for the nest hour.

    Therefore when I am missing a value say the 4th minute I will get the average of 4 cells. But for the 5minutes after I will have the correct average and will not be 1 minute off.

    I hope this is clear , does anybody have any idea how to do this , it doesn’t need to use the code ive been using already , if its no use i have attached the workbook i am using if this helps anybody .

    Thank you in advance

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,450

    Re: Averaging a range with missing values

    In 2007, you can probably use AVERAGEIFS rather than just AVERAGE.

    Alternatively, just use SUM/COUNTIF(not blank or not zero)

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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