Average a range between 2 dates

edwardj3

New Member
Joined
Jan 16, 2018
Messages
41
Office Version
  1. 365
Platform
  1. Windows
Hi Forum,
Hope you can help.

I have a worksheet updating every Monday with result from the previous week using VBA and appends to the right of the last entry.

When a month is complete I am then required to report the average of the data points - each day has 24 data points for each hour so month of May (31x24) had 744 data points.

Simple enough to manually return the result but is it possible to do it via either a formula or VBA?

I can't find a solution that sums / averages multiple rows between 2 dates so my current solution sums the total for each hour row
=SUMIFS(Historic_data!$B2:$ZZ2,Historic_data!$B$1:$ZZ$1,">="&B$2,Historic_data!$B$1:$ZZ$1,"<="&B$1)
B1 and B2 are the start and end dates of a month

I then sum these totals and divide by the number of data points to return the average

My date range currently goes from 1st Apr 23 to 4th Jun and increases weekly. Example below of Historic_date table layout

Hour01/04/202302/04/202303/04/2023
00:00​
187238242
01:00​
188220224
02:00​
186216215
03:00​
190224226
04:00​
198222220
05:00​
190207215
06:00​
192241229
07:00​
204218238
08:00​
245224242
09:00​
311222256
10:00​
348211263
11:00​
293217262
12:00​
265213236
13:00​
230212296
14:00​
230218237
15:00​
225221247
16:00​
231248238
17:00​
221256253
18:00​
220257268
19:00​
233224272
20:00​
217215276
21:00​
221206252
22:00​
226207274
23:00​
213214267

Hope you can help. If you need more info please get in touch.

Thank
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
How about
Excel Formula:
=AVERAGE(FILTER(Historic_data!$B2:$ZZ25,(Historic_data!$B$1:$ZZ$1>=B$2)*(Historic_data!$B$1:$ZZ$1<=B$1)))
 
Upvote 0
How about
Excel Formula:
=AVERAGE(FILTER(Historic_data!$B2:$ZZ25,(Historic_data!$B$1:$ZZ$1>=B$2)*(Historic_data!$B$1:$ZZ$1<=B$1)))
Briliant. The formula results matches what we've done manually.
Thank you @Fluff
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,963
Members
449,094
Latest member
Anshu121

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