|
各位大师好。之前杨建营老师出手相助写了类似的打印代码解决了的难题再次表示感谢,无奈自己才疏学浅更改不成恳求大家帮忙改一下万分感谢!
以下是另外打印代码:
Sub test()
Dim i&, j&, k&, m&, n&
Dim arr, brr, crr, drr, bm
Application.ScreenUpdating = False
With Sheets("申请明细")
arr = .[a1].CurrentRegion.Resize(, 6)
drr = .[h1].CurrentRegion
bm = InputBox("请输入编码:", "提示", "TZs0001")
If bm = "" Then Exit Sub
End With
With Sheets("明细打印")
brr = .Range("A2:P3")
ReDim crr(1 To 100, 1 To 16)
.[a5].CurrentRegion.Offset(5).Resize(, 16).ClearContents
For i = 3 To UBound(drr)
If arr(i, 2) = bm Then
brr(1, 2) = arr(i, 3)
brr(1, 6) = arr(i, 4)
brr(1, 16) = arr(i, 2)
brr(2, 2) = arr(i, 5)
brr(2, 6) = arr(i, 6)
brr(2, 16) = arr(i, 1)
m = m + 1
For j = 1 To UBound(drr, 2)
crr(m, j) = drr(i, j)
Next
End If
Next
If m > 0 Then
.[a2].Resize(2, 16) = brr
.[a6].Resize(m, 16) = crr
ActiveWindow.ScrollRow = 1
Sheets("明细打印").Activate
End If
End With
Application.ScreenUpdating = True
End Sub
|
|