|
呵呵。我的代码在“数据源”工作表中,你看到的代码是你原来代码。
点击上、下箭头,表面上没看到反应,当你点击打印按钮时,就起作用了。因为查找是由打印按钮引起的。
Sub 批量打印()
Set sh2 = Sheets("打印用")
If sh2.[o3] = "" Or sh2.[o3].Value < sh2.[o1].Value Then
MsgBox "请检查O1单元格编号或O3单元格编号!", 48, "警告!!!": Exit Sub
End If
k = sh2.[o1]
For i = k To sh2.[o3]
sh2.[o1] = i
Call 打印指定页
Next i
End Sub
Sub 打印指定页()
Call 查找
Set sh2 = Sheets("打印用")
sh2.[a1:j30].PrintOut Copies:=1
End Sub
Sub 查找()
Set sh1 = Sheets("数据源")
Set sh2 = Sheets("打印用")
arr = sh1.UsedRange
With sh2
If .[o1] = "" Then
.[c3].ClearContents
.[e3].ClearContents
.[g3].ClearContents
.[c4].ClearContents
.[c6].ClearContents
.[c8].ClearContents
.[c12].ClearContents
.[g12].ClearContents
.[j12].ClearContents
End If
If .[o1].Value > UBound(arr) - 1 Then MsgBox "O1单元格输入编号超出范围!", 48, "警告!!!": Exit Sub
For i = 1 To UBound(arr)
If arr(i, 1) = .[o1] Then
.[c3] = arr(i, 2)
.[e3] = arr(i, 3)
.[g3] = arr(i, 4)
.[c4] = arr(i, 5)
.[c6] = arr(i, 6)
.[c8] = arr(i, 7)
.[c12] = arr(i, 8)
.[g12] = arr(i, 9)
.[j12] = arr(i, 10)
Exit For
End If
Next i
End With
End Sub
|
评分
-
1
查看全部评分
-
|