I have this loop to take groups of 4 cells in one worksheet and average them into another worksheet. When the one line reads z = z+3 it runs, but if I change it to z = z+4 it doesn't (Runtime error 1004 Unable to get the Average property of the WorksheetFunction class). Why is this?
Dim summary As Worksheet
Set summary = ThisWorkbook.Sheets("Sheet3")
Dim cost As Worksheet
Set cost = ThisWorkbook.Sheets("Sheet4")
Dim y As Integer
Dim z As Integer
z = 2
For y = 2 To 17
cost.Cells(y, 3) = Round(Application.WorksheetFunction.Average(Range(summary.Cells(4, z), summary.Cells(4, (z + 3)))), 0)
z = z + 4
Next y
$BQ$4?Application.Average(...