I'm trying to create an array of ranges to use with the average function, I would like each range to be processed and the average value found to be printed. I'm getting error 1004 "unable to get average property of worksheet function"
Private Sub CommandButton3_Click()
Dim Ranges(1 To 7) As String
Dim i As Long
Dim RngAvrg1 As Long
Ranges(1) = "C:C"
Ranges(2) = "D:D"
Ranges(3) = "E:E"
Ranges(4) = "F:F"
Ranges(5) = "G:G"
Ranges(6) = "H:H"
Ranges(7) = "I:I"
i = 1
Do Until i = 7
RngAvrg1 = Application.WorksheetFunction.Average(Worksheets("Task_Data").Range(Ranges(i)))
Sheets("Task_Data").Range("L" & i).Value = RngAvrg1
i = i + 1
Loop
End Sub
Bookmarks