ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   looping programing help (https://www.excelbanter.com/excel-programming/427617-looping-programing-help.html)

russ70

looping programing help
 
I have no idea how to program macros but there has to be an easier way...

I have 100 days of hourly data in one column (c1). I need to find the
average value of r1-24 and put it in c2r1. Then the average value of r25-r48
in c2r2. This need to repeat until all 100 days are done.

I need to summarize the data in many different ways (mean, max, min, etc.)
but figure I can edit the macro to do each when it is done. I would really
appreciate someones help to write a quick macro. thanks in advance.-r

OssieMac

looping programing help
 
I assume that you have 2400 rows of data. 24 rows for each day. Is this
correct?

I also assume from your post that you do not have column headers and the
actual data starts in cell A1.

If above is correct then if the data is in column A then in column B insert
the numbers 1 to 100 in the first 100 rows. (Just insert 1 in the first cell,
2 in the second and 3 in the third row then select the 3 cells and then drag
down and Autofill).

In the cell C1 insert the following formula:-
=AVERAGE(OFFSET($A$1,($B1-1)*24,0):OFFSET($A$1,($B1-1)*24+23,0))

NOTE: If you have column headers and the data starts in in cell A2 then the
1 to 100 will start in B2 and the formula will be as follows:-
=AVERAGE(OFFSET($A$2,($B2-1)*24,0):OFFSET($A$2,($B2-1)*24+23,0))

You can use similar addressing in the adjacent columns D, E etc for MAX,
MIN, MEDIAN etc. Copy and paste the formula and just replace AVERAGE.

If using any other formulas then the 2 offsets simply replace cell reference
ranges in groups of 24. Note the colon (:) between the offsets.

--
Regards,

OssieMac


"russ70" wrote:

I have no idea how to program macros but there has to be an easier way...

I have 100 days of hourly data in one column (c1). I need to find the
average value of r1-24 and put it in c2r1. Then the average value of r25-r48
in c2r2. This need to repeat until all 100 days are done.

I need to summarize the data in many different ways (mean, max, min, etc.)
but figure I can edit the macro to do each when it is done. I would really
appreciate someones help to write a quick macro. thanks in advance.-r



All times are GMT +1. The time now is 12:18 AM.

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