average range of data with missing cells (VBA)

mdavid800

New Member
Joined
Jul 27, 2011
Messages
6
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.

Code:
 Sub Average_5min()
Dim i As Long
For i = 2 To 43173 Step 5
    Range("N" & Rows.Count).End(xlUp).Offset(1).Value = WorksheetFunction.Average(Range("F" & i).Resize(5))
Next i
End Sub

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.( 1 to 5 , then 6 to 10 and so on). 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.

Thank you in advance
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top