|
因为办公电脑有加密,发不了附件
Sub 领料单打印()
' https://club.excelhome.net/threa ... tml?_dsign=68639f0d
' 2024-4-18
Sheet6.Select
Range("A6:G15").ClearContents
'-----
c_dh = Sheet6.Cells(3, 6).Value
If IsEmpty(c_dh) Then
MsgBox "单据号不能为空!!!"
Exit Sub
End If
'------
x5 = 2
foun = False
sn = 0
Do While Not (IsEmpty(Sheet5.Cells(x5, 1).Value))
If Sheet5.Cells(x5, 1).Value = c_dh Then
sn = sn + 1
foun = True
Sheet6.Cells(3, 2).Value = Sheet5.Cells(x5, 2).Value
Sheet6.Cells(4, 2).Value = Sheet5.Cells(x5, 3).Value
Sheet6.Cells(4, 6).Value = Sheet5.Cells(x5, 4).Value
Sheet6.Cells(17, 2).Value = Sheet5.Cells(x5, 12).Value
Sheet6.Cells(17, 4).Value = Sheet5.Cells(x5, 13).Value
Sheet6.Cells(17, 6).Value = "领料人:" & Sheet5.Cells(x5, 14).Value
End If
x5 = x5 + 1
Loop
If foun = False Then
MsgBox "请正确输入单据号!!!"
Exit Sub
End If
'------
x5 = 2
x1 = 1
Do While Not (IsEmpty(Sheet5.Cells(x5, 1).Value))
If Sheet5.Cells(x5, 1).Value = c_dh Then
For y = 1 To 14
Sheet1.Cells(x1, y).Value = Sheet5.Cells(x5, y).Value
Next y
x1 = x1 + 1
End If
x5 = x5 + 1
Loop
'--完成数据转移到“开单过渡表”上
If sn > 9 Then
For x = 1 To 9
For y = 1 To 7
Sheet6.Cells(x + 5, y).Value = Sheet1.Cells(x, y + 4).Value
Next y
Next x
'ActiveWindow.SelectedSheets.PrintOut ' 不预览,直接打印
ActiveWindow.SelectedSheets.PrintPreview ' 预览,人控打印 第一张打印
Sheet6.Select
Range("A6:G15").ClearContents
For x = 10 To sn
For y = 1 To 7
Sheet6.Cells(x - 4, y).Value = Sheet1.Cells(x, y + 4).Value
Next y
Next x
ActiveWindow.SelectedSheets.PrintPreview ' 预览,人控打印 第二张打印
Else
For x = 1 To sn
For y = 1 To 7
Sheet6.Cells(x + 5, y).Value = Sheet1.Cells(x, y + 4).Value
Next y
Next x
ActiveWindow.SelectedSheets.PrintPreview ' 预览,人控打印 只打印一张
End If
End Sub |
评分
-
1
查看全部评分
-
|