ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro that calculates average (https://www.excelbanter.com/excel-programming/336974-macro-calculates-average.html)

jaguarr

macro that calculates average
 

I have Excel data similar to the structure below

columnA Column B Column C Column D
month day time temperature
1 1 100 32
1 1 130 33
1 2 100 29
1 2 130 35
1 2 200 33
1 2 230 36

I would like to calculate the daily average temperatures. It would b
easy if every month have the exact same number of days, but it doesn't
and I have many years and many months to calculate, so I think macro i
the easiest and fastest way to do this.

Could someone write a basic macro that will calculate the daily averag
temperature? I assume one 'if statement' would be to check if the da
(column B) is the same.

thanks for any input

--
jaguar
-----------------------------------------------------------------------
jaguarr's Profile: http://www.excelforum.com/member.php...fo&userid=2615
View this thread: http://www.excelforum.com/showthread.php?threadid=39478


Jim Thomlinson[_4_]

macro that calculates average
 
This is much more easily accomplished with a pivot table. Take your Month /
Day / Year / Time columns and create an actual single Date and Time column
(you probably don't need the time data and it could get in the way if you end
up with more than 8,000 unique values for Date and Time so you probably don't
want it). You can then pivot that data grouping on the Date (into months,
quarters, years) and aggregating with the average function. This is a little
bit advanced in terms of pivot tables so let me know if you need any help. If
it was me I would create a sheet that looked like this...

month day Date time temperature
1 1 1/1/2005 100 32
1 1 1/1/2005 130 33
1 2 1/2/2005 100 29
1 2 1/2/2005 130 35
1 2 1/2/2005 200 33
1 2 1/2/2005 230 36


Which will pivot very nicely...

--
HTH...

Jim Thomlinson


"jaguarr" wrote:


I have Excel data similar to the structure below

columnA Column B Column C Column D

I would like to calculate the daily average temperatures. It would be
easy if every month have the exact same number of days, but it doesn't,
and I have many years and many months to calculate, so I think macro is
the easiest and fastest way to do this.

Could someone write a basic macro that will calculate the daily average
temperature? I assume one 'if statement' would be to check if the day
(column B) is the same.

thanks for any input.


--
jaguarr
------------------------------------------------------------------------
jaguarr's Profile: http://www.excelforum.com/member.php...o&userid=26150
View this thread: http://www.excelforum.com/showthread...hreadid=394787




All times are GMT +1. The time now is 06:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com