Hello All,
I was hoping anyone could help me with a large excel file I am analysing. I have weather data for a considerable amount of time taken at 15 minute intervals. I would like to average this data into hourly intervals. As a result, I would like help writing a macro that would insert a blank row after every fourth row. After that, I would like to have the averages of each column's 1-4 rows averaged. I've found some code online and changed it to insert a row every fifth row, but it only averages the data in column A. I would like it to average columns A through H. Below is the code:
Const xlShiftDown = -4121
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Open("C:\Scripts\4-9 to 4-17 Weather Data-1")
Set objWorksheet = objWorkbook.Worksheets(1)
i = 1
j = 1
Do Until objWorksheet.Cells(i, 1) = ""
If j = 5 Then
Set objRange = objWorksheet.Cells(i, 1).EntireRow
objRange.Insert (xlShiftDown)
strFormula = "=average(A" & i - 1 & ":A" & i - 4 & ")"
objWorksheet.Cells(i, 1) = strFormula
objWorksheet.Cells(i, 1).Interior.ColorIndex = 44
j = 0
End If
j = j + 1
i = i + 1
Loop
TIA,
Josh
Bookmarks