|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
回复 5楼 carol010109 的帖子
如有乱码,请复制下面代码贴上:
Private Sub CommandButton1_Click()
Dim i, j, k, m, n, p As Long
With Sheets("交货标签")
.Range("B3:B10, E3:E10, H3:H10").ClearContents
.Range("B14:B21, E14:E21, H14:H21").ClearContents
.Range("B25:B32, E25:E32, H25:H32").ClearContents
.Range("B36:B43, E36:E43, H36:H43").ClearContents
.Range("B47:B54, E47:E54, H47:H54").ClearContents
.Range("B58:B65, E58:E65, H58:H65").ClearContents
End With
m = -1: k = 3
For i = 2 To Sheets("交货清单").[A65536].End(xlUp).Row
p = p + 1 '笔数
If m < 8 Then
m = m + 3
If n < 14 Then
n = k - 1
Else
n = n - 8
End If
Else
m = -1
m = m + 3
n = n + 3
End If
For j = 2 To 9
n = n + 1
Sheets("交货标签").Cells(n, m) = Sheets("交货清单").Cells(i, j)
Next j
If p = 18 Then
With Sheets("交货标签")
With .PageSetup
.PrintArea = "交货标签!$A$1:$H$65"
.PaperSize = xlPaperA4
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
.PrintOut Copies:=1, Collate:=True
.Range("B3:B10, E3:E10, H3:H10").ClearContents
.Range("B14:B21, E14:E21, H14:H21").ClearContents
.Range("B25:B32, E25:E32, H25:H32").ClearContents
.Range("B36:B43, E36:E43, H36:H43").ClearContents
.Range("B47:B54, E47:E54, H47:H54").ClearContents
.Range("B58:B65, E58:E65, H58:H65").ClearContents
m = -1: k = 3: p = 0: n = 0
End With
End If
Next i
End Sub
[ 本帖最后由 mineshine 于 2009-4-10 12:01 编辑 ] |
|