我正在为从excel打印的一系列标签设置增量打印。每页有四个标签编号,具有重复值(每页共8个标签)。我附上了一个屏幕截图的文件。https://i.stack.imgur.com/jfSoz.png。第一个标签编号26000将在脚本中引用,其余的将通过公式更新以在该编号上加上+1。我希望每次打印任何给定数量的工作表时都要重新填充第一个数字。我已经将下面的脚本组合在一起,但每次打印时都不会显示正确的数字。它不是在顶部继续下一个系列,26005,而是显示5。如有任何帮助或建议,我们将不胜感激。
子PrintNext5()
Dim xCount As Variant
Dim xScreen As Boolean
Dim I As Integer
On Error Resume Next
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"
Else
xScreen = Application.ScreenUpdating
Application.ScreenUpdating = False
For I = 1 To xCount
ActiveSheet.Range("C3").Value = Range("C3" + 5)
ActiveSheet.PrintOut
Next
Application.ScreenUpdating = xScreen
End If结束子对象
发布于 2021-04-21 06:14:37
据我所知,你的计数器计数不正确
尝试将计数器初始化为所需的第一个值(第一个值加上标签计数)
检查代码
祝好运
Sub PrintNext5()
Dim xCount As Variant
Dim xScreen As Boolean
Dim I As Integer
On Error Resume Next
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"
Else
xScreen = Application.ScreenUpdating
Application.ScreenUpdating = False
'your counter I in this case, should begin in 26000 and xCount should be xCount + 26000
'you can try assign name to a cell in order to call it as name
'begins = Sheets("otherSheet").Range("A1") <--Catch the first value from a cell
For I = 26000 To xCount + 26000
ActiveSheet.Range("C3").Value = I
ActiveSheet.PrintOut
I = I + 5 '<-- Your picture has 4 labels 1, 2, 3, 4, we are in 1 plus 4 = 5, next round begin in 5, 6, 7, 8,
Next
Application.ScreenUpdating = xScreen
End If
End Subhttps://stackoverflow.com/questions/67185878
复制相似问题