I'm trying to clculate a formula that takes number from Column D and calcultes this number minus 14 in column C. Then, I'm triyng to autofill the range down to the first cell I calculate.
at first it was working, but now it shows me an error:
appliction-defined or object-defined error
to this line of code
Selection.AutoFill Destination:=ActiveCell.Range("A1:A" & lastrow)
If someone would help me to solve this prblem I'll be glad.
OP_wb.Sheets("Optic Main").Activate
Dim FirstRow As Range
Dim lastrow As Range
Set FirstRow = Range("C1").End(xlDown).Offset(1, 0)
Set lastrow = Range("E1").End(xlDown).Offset(0, -2)
Range("E1").End(xlDown).Offset(0, -2).Select
Range(FirstRow, lastrow).FormulaR1C1 = "=(c4-14)"
Selection.AutoFill Destination:=ActiveCell.Range("A1:A" & lastrow)
