Sub 打印()
Dim r As Long, S1 As Worksheet, S2 As Worksheet, r1, r2
Set S1 = Sheets("打印模板")
Set S2 = Sheets("历史数据记录")
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True '打印
r = S2.[A65536].End(xlUp).Row + 1 'Sheets("历史数据记录")最后空白行
With S1
r1 = .Columns(7).Find("医疗备件").Row + 1
r2 = .Cells(.Rows.Count, 7).End(3).Row
arr = .Range("g" & r1, "g" & r2)
'Sheets("5月份账单")最后空白行的A:M写入数组:"打印模板"工作表的"日期,收货人,收货人地址,目的地,件数,重量,体积,费率,应收,派送日期,手机号,电话,尺寸"
S2.Cells(r, 1).Resize(, 13) = Array(.[B46], .[A17], .[B20], .[D4], .[A26], .[E26], .[J34], .[B31], .[B39], .[J10], .[B23], .[C17], tiqu(arr))
End With
End Sub
Function tiqu(arr)
tiqu = Join(WorksheetFunction.Transpose(arr), ",")
End Function
复制代码 |