|
Sub 打印初中()
Application.ScreenUpdating = False '关闭屏幕刷新
Set sh1 = Sheets("中学")
Set sh2 = Sheets("数据源(中学)")
s = sh1.Cells(1, 15)
e = sh1.Cells(1, 17)
If s = "" Or Not VBA.IsNumeric(s) Or Not VBA.IsNumeric(e) Then MsgBox "请先设置打印的开始序号"
If Val(s) > Val(e) Then MsgBox "开始序号不能大小于终止序号!"
r = 5
c = 0
For i = s To e
Set cx = sh2.Range("a:a").Find(i, lookat:=xlWhole)
If Not cx Is Nothing Then
c = c + 3
sh1.Cells(r, c) = sh2.Cells(cx.Row, 2)
sh1.Cells(r + 1, c) = sh2.Cells(cx.Row, 3)
sh1.Cells(r + 2, c) = sh2.Cells(cx.Row, 4)
If i = e Or (r = 11 And c >= 11) Then
[a1:l13].PrintOut
End If
If c >= 11 Then
r = r + 6
c = 0
If r > 11 Then r = 5
End If
End If
Next i
Application.ScreenUpdating = True '打开屏幕刷新
End Sub
|
评分
-
1
查看全部评分
-
|