I have some VBA code where I want to copy a formula into a range of cells using R1C1. Unfortunately I get the following error on the second to last line:
Runtime error '1004': Application-defined or object-defined error.
Dim pct As Single
pct = 1
With ThisWorkbook.Sheets("Data").UsedRange
Dim lastR As Long
lastR = .Rows.Count
Dim lastC As String
lastC = col_letter(.Columns.Count)
End With
With ThisWorkbook.Sheets("Calculations")
.Range("A1:" & lastC & 1).Value = 100
==> .Range("A2:" & lastC & lastR + 1).FormulaR1C1 = "=R[-1]C*(1+" & pct / 100 & "*'Data'!R[-1]C"
End With
What am I doing wrong here?
lastCandlastRcurrent values when error occurs?lastC= "CU";lastR= 1000;pct= 0.1