Reputation: 39
I'm using following subprocedure to fill some cells starting with cell AS9 but somehow the subprocedure modifies also the header from AS8. I don't want to modify the header when I run the subprocedure
Sub actualizareformule()
Dim Lastrow As Long
Application.ScreenUpdating = False
Lastrow = Range("L" & Rows.Count).End(xlUp).Row
Range("AS9:AS" & Lastrow).Formula = _
"=IFERROR(RC[-2]/RC[-1],""0%"")"
ActiveSheet.AutoFilterMode = False
Application.ScreenUpdating = True
End Sub
Upvotes: 0
Views: 50
Reputation: 1645
You should add one to last row. This way you will add your formula starting from next row (one below). Try this:
Sub actualizareformule()
Dim Lastrow As Long
Application.ScreenUpdating = False
'Find last row and add one
Lastrow = Range("L" & Rows.Count).End(xlUp).Row + 1
Range("AS9:AS" & Lastrow -1).Formula = "=IFERROR(RC[-2]/RC[-1],""0%"")"
ActiveSheet.AutoFilterMode = False
Application.ScreenUpdating = True
End Sub
Upvotes: 1