我有这段代码可以在打印后增加一个单元格,但是我不知道如何更改起始值。现在,它从1开始,但是此表格已经被手动使用了很长时间,所以我需要在105,300左右开始
我尝试更改该行中单元格(G9)的值
ActiveSheet.Range("G9").Value = "" & I
,但始终会重置。例如,我打印3份副本,然后进行序列处理。我再打印5张,但作为起点,它又恢复为105290。
Sub Macro1()
Dim xCount As Variant
Dim xScreen As Boolean
Dim I As Long
On Error Resume Next
LInput:
xCount = Application.InputBox("Please enter the number of copies you want to print:")
If TypeName(xCount) = "Boolean" Then Exit Sub
If (xCount = "") Or (Not IsNumeric(xCount)) Or (xCount < 1) Then
MsgBox "error entered, please enter again", vbInformation
GoTo LInput
Else
xScreen = Application.ScreenUpdating
Application.ScreenUpdating = False
For I = 1 To xCount
ActiveSheet.Range("G9").Value = "" & I
ActiveSheet.PrintOut
Next
ActiveSheet.Range("G9").UpdateContents
Application.ScreenUpdating = xScreen
End If
End Sub
我正在寻找可以不断更新单元格的方法,因此用户不必手动执行此操作。