My Goal would be to control a formula from the first worksheet with this code on the second worksheet (same workbook).
Dim ERP As Worksheet
Set ERP = ThisWorkbook.Worksheets(2)
ERP.Activate
ERP.Range("O1").Value = "Korositás intervallum"
ERP.Range("O2").Activate
ActiveCell.FormulaR1C1 = _
"=IFS(RC[-1]<=0,""nem lejárt"",AND(RC[-1]>=1,RC[-1]<=30),""1-30"",AND(RC[-1]>=31,RC[-1]<=60),""31-60"",AND(RC[-1]>=61,RC[-1]<=90),""61-90"",AND(RC[-1]>=91,RC[-1]<=120),""90-120"",AND(RC[-1]>=121,RC[-1]<=180),""121-180"",AND(RC[-1]>=181,RC[-1]<=360),""181-360"",RC[-1]>361,""360 nap feletti tartozás"")"
ERP.Range("O2").Select
Selection.AutoFill Destination:=Range("O2:O1301")
However it keeps running on error on the last statement
Strange thing is if I run this code embedded on the second worksheet it runs perfect.
Could you please advise what could be the problem ?
Thanks Andras