Hi guys, I have query which calculates and autofills columns, but there's a problem "run-time error 6" on 3rd row.
________________
Sub Macros()
Dim lastOne As Integer
lastOne = Worksheets(1).Cells(Rows.Count, 2).End(xlUp).Row
Range("H1").Value = "Cost1"
Range("I1").Value = "Cost2"
Range("J1").Value = "Cost3"
Range("K1").Value = "Value"
Range("K1").Select
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
Range("H2").Select
ActiveCell.FormulaR1C1 = "=R[+1]C[-3]+RC[-3]"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=R[+1]C[-3]+RC[-3]"
Range("J2").Select
ActiveCell.FormulaR1C1 = "=R[+1]C[-3]+RC[-3]"
Range("K3").Select
ActiveCell.FormulaR1C1 = "=RC[-1]-R[-1]C[-1]"
Range("H2:K2").AutoFill Destination:=Range("H2:K2" & CStr(lastOne)), Type:=xlFillDefault
End Sub
_____________________________________
When I'm trying to change 'integer' to 'long' there's another problem "Run-time error 1004, Method 'Range' of object '_Global' Failed" on 21st row.
I would be appreciative for any advice.
Bookmarks