'Find the last used row in a Column: column A in this example
Dim lastRow As Long
With Worksheets("Summary")
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
'Inserts column on E
Columns("E:E").Select
Selection.Insert Shift:=xlToRight
'Titles header "Net Return"
Range("E3").FormulaR1C1 = "Net Return"
'Places formula in cell E4
Range("E4").FormulaR1C1 = "=RC[-2]-RC[-3]"
'Fills formula down row - this is where my code breaks
Range("E4").AutoFill Destination:=Range("E4:(lastRow - 1)"), Type:=xlFillDefault
I want to insert new column on E, input the formula =(C4-B4) in cell E4 and fill down until lastRow. How can I utilize lastRow when declaring the range of cells to populate my formula in? I receive runtime error 1004 on my .Autofill line.
Range(Cells(4,5), Cells(lastRow-1, 5)).FillDown? Or, even, skip that step and just do it in one:Range("E4:E" & (lastRow-1)).FormulaR1C1 = "=RC[-2]-RC[-3]"- Chronocidal