我想在一个单元格的范围内添加一个公式。它应该把一个相邻的细胞乘以100。在此之前,我尝试了以下几点:
Range(Cells(row, col + 17), Cells(row + num_positions, col + 17)).Select
Selection.Formula = "=100*" & Cells(row, col + 12)
不幸的是,这不是正确的语法。如何运用这样的行为?
编辑:
For i = 0 To num_n
v = Cells(row + i, col + 12)
Cells(row + i, col+ 17).Formula = "=100*" & v
Next i
如果我用常量表达式替换v
,这是可行的。
发布于 2014-07-31 06:31:14
使用FormulaR1C1
。就容易多了。如果可以的话,要避免循环,它们是慢的。
With Range(Cells(row, col + 17), Cells(row + num_positions, col + 17))
.FormulaR1C1 = "=100*RC[-5]" '100 times the cell on the same row, 5 cols left
End with
https://stackoverflow.com/questions/25060669
复制