我有一些 VBA 代码,我想将公式复制到使用R1C1
. 不幸的是,我在倒数第二行收到以下错误:
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
我在这里做错了什么?