我想动态地设置在我的宏执行时输入公式的单元格。这段代码将循环大约10次,每次都有一部分员工。按部门排序。所以当循环回到这一点时,第一个单元格将会改变。1004错误 - 动态分配公式到一个单元格范围
我得到这个错误:
Method 'Range' of object '_Global' failed
这里是我的代码:
'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
提前感谢!
哪一行会抛出错误? – RBarryYoung 2012-04-10 19:39:02
什么是错误信息的文本? (1004至少有两个不同的)。 – RBarryYoung 2012-04-10 19:42:42