|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 凭证打印()
Dim ar As Variant
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("凭证汇总表")
r = .Cells(Rows.Count, 7).End(xlUp).Row
If r < 3 Then MsgBox "凭证汇总表为空!": End
ar = .Range("a2:l" & r)
End With
For i = 2 To UBound(ar)
For j = 1 To 6
If ar(i, j) = "" Then
ar(i, j) = ar(i - 1, j)
End If
Next j
If d(ar(i, 5)) = "" Then
d(ar(i, 5)) = i
Else
d(ar(i, 5)) = d(ar(i, 5)) & "|" & i
End If
Next i
With Sheets("记账凭证")
For Each k In d.keys
.Range("a4:i9") = Empty
rr = Split(d(k), "|")
n = 3
For i = 0 To UBound(rr)
xh = rr(i)
n = n + 1
.Cells(n, 1) = ar(xh, 6)
.Cells(n, 2) = ar(xh, 8)
.Cells(n, 3) = ar(xh, 9)
.Cells(n, 4) = ar(xh, 10)
.Cells(n, 7) = ar(xh, 11)
.[d2] = ar(xh, 1) & "/" & ar(xh, 2) & "/" & ar(xh, 3)
.[f2] = ar(xh, 5)
.[h2] = ar(xh, 12)
Next i
.PrintOut
Next k
End With
MsgBox "打印完毕!", 64, "提醒!"
End Sub
|
|