- Sub Test()
- Dim mBrr(1 To 8, 1 To 5), Arr, Brr, i&, j&, StarTNumber, EndNumBer, x, tmProw%
- For i = 1 To 8
- mBrr(i, 1) = Array("单位:KG", "车 号", "货 名", "发货区域", "发货单位", "收货单位", "承运单位", "过 磅 员")(i - 1)
- mBrr(i, 3) = Array("", "毛 重", "皮 重", "净 重", "毛重时间", "皮重时间", "实际净重", "备 注")(i - 1)
- Next i
- mBrr(2, 1) = "记录时间:": mBrr(4, 1) = "单据号:"
- Arr = Sheet11.[a1].CurrentRegion
- With Sheet1
- StarTNumber = .[g1] & ""
- EndNumBer = .[g3] & ""
- x = 0
- For i = 2 To UBound(Arr, 1)
- If Arr(i, 1) & "" >= StarTNumber And Arr(i, 1) & "" <= EndNumBer Then
- x = x + 1
- If x = 1 Then Call 模板清空
-
- Brr = mBrr
- For j = 1 To 6
- Brr(j + 1, 2) = Arr(i, j + 2)
- Next j
- For j = 2 To 7
- Brr(j, 4) = Arr(i, j + 7)
- Next j
- Brr(1, 3) = Arr(i, 2)
- Brr(1, 5) = Arr(i, 1)
- Brr(8, 2) = Arr(i, 15): Brr(8, 4) = Arr(i, 16)
- tmProw = Array(4, 16, 28)(x - 1)
- .Cells(tmProw, 1).Resize(UBound(Brr, 1), UBound(Brr, 2)) = Brr
- If x = 3 Then .PrintOut: x = 0
- End If
- Next i
- If x Then .PrintOut
- End With
- End Sub
复制代码 |