Results 1 to 2 of 2

Averaging Weather Data

Threaded View

  1. #1
    Registered User
    Join Date
    05-07-2008
    Posts
    1

    Averaging Weather Data

    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
    Last edited by rylo; 05-07-2008 at 08:13 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1