
给你做了一个代码,试试吧
Sub 提取1()Dim ck As String
Set sh = Sheets("sheet1") '中间结果表
Set Sh2 = Sheets("单据打印")
Sh2.Select
ck = Range("i2") '出库单号
Range("a5:m21").ClearContents '清除旧数据
sh.Select
Cells.ClearContents
With Sheets("出库")
x = .Range("a65536").End(xlUp).Row
y = .Range("a1").End(xlToRight).Column
s = 2
For i = 1 To y
Cells(1, i).Value = .Cells(1, i).Value
Next
For i = 2 To x
If .Cells(i, 1) = ck Then
For j = 1 To y
Cells(s, j).Value = .Cells(i, j).Value
Next
s = s + 1
End If
If s = 2 Then MsgBox "没有数据": Exit Sub
Next
End With
'删除空列
For i = y To 7 Step -1
If WorksheetFunction.CountA(Range(Cells(2, i), Cells(s, i))) = 0 Then
Columns(i).Delete Shift:=xlToLeft
End If
Next
'判断列数是否超过打印表宽度
ls = 13 '打印表中除“形体”+“颜色”+“号段”有13列
y = Range("a1").End(xlToRight).Column
If y > ls Then
MsgBox "超过打印宽度,需要手工填写表格"
Exit Sub
End If
'粘贴到打印表
With Sh2
x = Range("a65536").End(xlUp).Row
.Range("B3") = Range("f2") '客户
.Range("f3") = Range("c2") '订单
.Range("j3") = Range("b2") '日期
.Range("a5:b" & x + 4).Value = Range("d1:e" & x).Value '形体与颜色
.Range("c5:m" & x + 4).Value = Range("g1:q" & x).Value '号段
End With
Sh2.Select
MsgBox "完毕"
End Sub
出库单加行数打印不出来原因是打印机设置问题、电脑设置问题。1、打印机设置问题:在打印出库单加行数时,需要确保打印机设置正确,例如打印机是否已连接、是否已安装好驱动程序等,这些可能是导致打印出库单加行数不能正常工作的常见问题。
2、电脑设置问题:在电脑上打印出库单加行数时,也需要确保设置正确,例如关键字是否正确、格式是否正确等。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)