|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
求助大神,帮忙看看这个宏内容,哪里不对了,
目标:在自动打印的同时,超行自动换页打印
内容:
Sub 出库单打印()
Dim arr, i&, j&, x, d, brr, n, kh, dh
Set d = CreateObject("scripting.dictionary")
arr = Sheets(1).[a1].CurrentRegion
For i = 2 To UBound(arr)
x = arr(i, 1): d(x) = ""
Next
For Each x In d.keys
ReDim brr(1 To UBound(arr), 1 To 18)
For i = 2 To UBound(arr)
If arr(i, 1) = x Then
kh = arr(i, 4): dh = x 'kh为客户名称,dh为单号
n = n + 1
brr(n, 1) = arr(i, 2): brr(n, 2) = arr(i, 3)
For j = 3 To 4
brr(n, j) = arr(i, j + 2)
Next j
If n = 10 Or i = UBound(arr) Then
m = m + 1
With Sheet2
.[a5:g14] = ""
.[a5].Resize(n, 10) = brr
End If
Next
With Sheets(2)
.[a5:g14].ClearContents
.[b3] = kh: .[g3] = dh
.[a5].Resize(n, 18) = brr
'.[a2:g18].PrintPreview
.[a2:g18].PrintOut
End With
Erase brr
n = 0
Next
End Sub
|
|