|
vba编辑器中代码如下:
Sub 保存()
Dim i&, a$, b&, j%
If Sheets("发货单首页").Cells(10, 1) <> "" Then
a = Sheets("卖出货物清单").Cells(65536, 2).End(3).Row + 1
b = Sheets("发货单首页").Cells(65536, 1).End(3).Row
j = 10
Do While Sheets("发货单首页").Cells(j, 2) <> ""
j = j + 1
Loop
If j = 10 Then
MsgBox "没有数据1"
Exit Sub
End If
For i = 10 To j - 1
With Sheets("卖出货物清单")
.Cells(a, 1) = a - 1
.Cells(a, 2) = Sheets("发货单首页").Cells(3, 2) '发货流水号
.Cells(a, 3) = Sheets("发货单首页").Cells(i, 1) '编码
.Cells(a, 4) = Sheets("发货单首页").Cells(i, 2) '名称
.Cells(a, 5) = Sheets("发货单首页").Cells(i, 3) '规格
.Cells(a, 6) = Sheets("发货单首页").Cells(i, 4) '数量
'.Cells(a, 7) = Sheets("发货单首页").Cells(i, 2) '进货单价
.Cells(a, 8) = Sheets("发货单首页").Cells(i, 5) '销售单价
.Cells(a, 9) = Sheets("发货单首页").Cells(20, 6) '已收邮费
'.Cells(a, 10) = Sheets("发货单首页").Cells(20, 6) '已付邮费
.Cells(a, 11) = Sheets("发货单首页").Cells(21, 6) '优惠
' .Cells(a, 12) = Sheets("发货单首页").Cells(i, 2) '利润
' .Cells(a, 13) = Sheets("发货单首页").Cells(b, 6) '小计
End With
'Sheets("发货单首页").Cells(i, 1) = ""
' Rows(i).ClearContents
a = a + 1
Next i
End If
Sheets("发货单首页").Cells(3, 2) = Sheets("发货单首页").Cells(3, 2) + 1
End Sub
Sub 打印()
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub
如果要情空数据,那就把第30行的
'Sheets("发货单首页").Cells(i, 1) = ""
前面的“'”去掉,成这样:
Sheets("发货单首页").Cells(i, 1) = "" |
|