Hi, I found a code on this forum to loop through every worksheet in the workbook and write "hello" in cell A1 for every worksheet. Instead of saying hello in A1 on every worksheet, I want the code to average numbers in column C in groups of four in each worksheet and have it recorded in column A. Here is my code:
Sub WorksheetLoops()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If InStr("Price", ws.Name) = 0 Then
Columns("A:A").ColumnWidth = 4.86
Range("A9").Select
ActiveCell.FormulaR1C1 = "=AVERAGE(R[-3]C[2]:RC[2])"
Range("A6:A9").Select
Selection.AutoFill Destination:=Range("A6:A101"), Type:=xlFillDefault
Range("A6:A101").Select
End If
Next ws
End Sub
For some reason it just runs the loop in the first worksheet. Does anyone know why?
Bookmarks