想要将给定的公式放在5个单元格中
'////j and p have been declared before as Double
For j = 5 To 9
p=j*4
Worksheets("Sheet1").Activate
Sheets("Sheet1").Cells(j, 5 + (3 * n) + 1 ).Select
ActiveCell.FormulaR1C1 = "=IFERROR(IF(ROW(RC[p])<255,""DATA N/A"",INDIRECT(ADDRESS(ROW(RC[p])-250,COLUMN(RC[p]),,,))/RC[p]-1),""DATA N/A"")"
Next j
ActiveCell ....行中存在运行时1004错误。我无法调试错误。有人请帮忙。
答案 0 :(得分:0)
您实际上并不希望字符串“p”出现在公式中。我不知道你的公式是否有效。
Sub x()
Dim j As Long, p As Long, n As Long
For j = 5 To 9
p = j * 4
Worksheets("Sheet1").Cells(j, 5 + (3 * n) + 1).FormulaR1C1 = "=IFERROR(IF(ROW(RC[" & p & "])<255,""DATA N/A"",INDIRECT(ADDRESS(ROW(RC[" & p & "])-250,COLUMN(RC[" & p & "]),,,))/RC[" & p & "]-1),""DATA N/A"")"
Next j
End Sub