Hi i'm trying to loop the following code to do the same thing on all the worksheets.
When run it does the initial activesheet spot on but when it loops to the next it does everything except the autofill and i can't work out why
if somebody can help i'd appreciate it
Code:Option Explicit Sub loopingCode() Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets Dim r As Long r = Cells(Rows.Count, "B").End(xlUp).Row On Error Resume Next With ws .Rows("1:2").Insert Shift:=xlDown .Range("AR3:AV3") = Array("Accrual", "Committed", "To Accrue Y/N", "Name", "To Post") .Range("AS3") = "Accrual" .Range("AR2") = "Accrual Date" .Range("AS2").FormulaR1C1 = "='[Finance Macro Vault.xls]Project Overview'!R4C13" .Range("AR4").FormulaR1C1 = "=IF(RC33<=R2C45,RC32,0)" .Range("AR4").AutoFill Destination:=Range("AR4:AR" & r) :mad: End With Next ws End Sub




Reply With Quote