【发布时间】:2012-04-23 02:41:27
【问题描述】:
我正在尝试动态设置在执行宏时输入公式的单元格。这段代码将循环大约 10 次,每次都有一个新的员工部分。由部门订购。所以当循环回到这一点时,第一个单元格将发生变化。
我得到这个错误:
对象“_Global”的方法“范围”失败
这是我的代码:
'Select the top cell in the "%Working" Column
Range(Cells(StartTemp, 9)).Select
'Insert the Formula - Billable/(Billable + Unbillable) * 100 into Column I for each section
'Formula is 'C4/(C4+C5)*100
Range(Cells(StartTemp, 9)).Formula = "=RC[-6]/(RC[-6]+RC[-5]) *100"
Range(Cells(StartTemp, 9)).Select
Selection.NumberFormat = "0.00%"
'Insert the Formula into all cells in the section for this group.
Selection.AutoFill Destination:=Range(Cells(StartTemp, 9), Cells(EndTemp, 9)), Type:=xlFillDefault
Range(Cells(StartTemp, 9), Cells(EndTemp, 9)).Select
提前致谢!
【问题讨论】:
-
哪一行报错?
-
错误信息的内容是什么? (1004 至少有两个不同的)。
标签: vba excel excel-2007 range formula