我想设置excel利用宏连续打印,编辑了一段代码,怎么都执行不了,请教各位大侠
Sub打印()''打印Macro'宏由雨林木风录制,时间:2011-3-23'DimiAsIntegerFori=0To1Range("E3:F3").SelectAct...
Sub 打印()
'
' 打印 Macro
' 宏由 雨林木风 录制,时间: 2011-3-23
'
Dim i As Integer
For i = 0 To 1
Range("E3:F3").Select
ActiveCell.FormulaR1C1 = "=Sheet2!R[3+i]C[18]"
Range("E4:F4").Select
ActiveCell.FormulaR1C1 = "=Sheet2!R[2]C[15]"
Range("B6").Select
ActiveCell.FormulaR1C1 = "=Sheet2!RC[10]"
Range("C6").Select
ActiveCell.FormulaR1C1 = "=Sheet2!RC[16]"
Range("D6").Select
ActiveCell.FormulaR1C1 = "=Sheet2!RC[6]"
Range("E6").Select
ActiveCell.FormulaR1C1 = "=Sheet2!RC[6]"
Range("F6").Select
ActiveCell.FormulaR1C1 = "=Sheet2!RC[10]"
Range("A1:F21").Select
Range("F21").Activate
Selection.PrintOut Copies:=1
Next i
End Sub
.Range("B6").FormulaR1C1 = "=Sheet2!R["i &"]C[10]"这句话说是缺少语句结束,是什么意思? 展开
'
' 打印 Macro
' 宏由 雨林木风 录制,时间: 2011-3-23
'
Dim i As Integer
For i = 0 To 1
Range("E3:F3").Select
ActiveCell.FormulaR1C1 = "=Sheet2!R[3+i]C[18]"
Range("E4:F4").Select
ActiveCell.FormulaR1C1 = "=Sheet2!R[2]C[15]"
Range("B6").Select
ActiveCell.FormulaR1C1 = "=Sheet2!RC[10]"
Range("C6").Select
ActiveCell.FormulaR1C1 = "=Sheet2!RC[16]"
Range("D6").Select
ActiveCell.FormulaR1C1 = "=Sheet2!RC[6]"
Range("E6").Select
ActiveCell.FormulaR1C1 = "=Sheet2!RC[6]"
Range("F6").Select
ActiveCell.FormulaR1C1 = "=Sheet2!RC[10]"
Range("A1:F21").Select
Range("F21").Activate
Selection.PrintOut Copies:=1
Next i
End Sub
.Range("B6").FormulaR1C1 = "=Sheet2!R["i &"]C[10]"这句话说是缺少语句结束,是什么意思? 展开
展开全部
Sub 打印()
Dim i As Integer
With Sheets("Sheet1")
For i = 0 To 1
.Range("E3:F3").FormulaR1C1 = "=Sheet2!R[" & 3 + i & "]C[18]"
.Range("E4:F4").FormulaR1C1 = "=Sheet2!R[2]C[15]"
.Range("B6").FormulaR1C1 = "=Sheet2!RC[10]"
.Range("C6").FormulaR1C1 = "=Sheet2!RC[16]"
.Range("D6").FormulaR1C1 = "=Sheet2!RC[6]"
.Range("E6").FormulaR1C1 = "=Sheet2!RC[6]"
.Range("F6").FormulaR1C1 = "=Sheet2!RC[10]"
.PrintOut Copies:=1
Next i
End With
End Sub
Dim i As Integer
With Sheets("Sheet1")
For i = 0 To 1
.Range("E3:F3").FormulaR1C1 = "=Sheet2!R[" & 3 + i & "]C[18]"
.Range("E4:F4").FormulaR1C1 = "=Sheet2!R[2]C[15]"
.Range("B6").FormulaR1C1 = "=Sheet2!RC[10]"
.Range("C6").FormulaR1C1 = "=Sheet2!RC[16]"
.Range("D6").FormulaR1C1 = "=Sheet2!RC[6]"
.Range("E6").FormulaR1C1 = "=Sheet2!RC[6]"
.Range("F6").FormulaR1C1 = "=Sheet2!RC[10]"
.PrintOut Copies:=1
Next i
End With
End Sub
展开全部
问题在于i作为变量要转换为字符。
Range("E3:F3").FormulaR1C1 = Trim("=Sheet2!R[" + Format(3 + i) + "]C[18]")
把那条语句改成这样就行了。
Range("E3:F3").FormulaR1C1 = Trim("=Sheet2!R[" + Format(3 + i) + "]C[18]")
把那条语句改成这样就行了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
.Range("B6").FormulaR1C1 = "=Sheet2!R["i &"]C[10]"这句话说是缺少语句结束,是因为你在i前面少了个“&”符号。整句应该是:
.Range("B6").FormulaR1C1 = "=Sheet2!R[" & i & "]C[10]"
.Range("B6").FormulaR1C1 = "=Sheet2!R[" & i & "]C[10]"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询