我试图调用一个包含VBA中的公式中的单元格地址的变量,但一直运行时错误1004。句法?如何在公式中使用变量vba excel运行时错误1004
ActiveCell.FormulaR1C1 = "=(RC[-1]/" & CellLocationCFYearTotal & ")* " & CellLocationCFYearDC & ""
或者我没有正确声明变量?
Dim RowLocationCFYearIDC As Long 'can hold over 32000 if over this many rows
Dim ColumnLocationCFYearIDC As Integer 'columns won't exceed 256 in sheet
Dim CellLocationCFYearIDC As String
CellLocationCFYearIDC = ActiveCell.Address
RowLocationCFYearIDC = ActiveCell.Row
ColumnLocationCFYearIDC = ActiveCell.Column
谢谢!
您正在混合公式中的R1C1和A1样式。所以更改'ActiveCell.Address'到'ActiveCell.Address(1,1,xlR1C1)'见:https://msdn.microsoft.com/en-us/library/office/ff837625.aspx –
非常感谢斯科特,只是回到这个和你的建议完美,因为我确定你知道。再次感谢! –