Sub 打印()
Sheets("票据打印").Select
ActiveWindow.SelectedSheets.PrintOut
With Sheets("记录")
x = .Range("a65536").End(xlUp).Row + 1
For i = 0 To 5
If .Cells(i + 4, 1) <> "" Then
.Cells(x + i, 1) = [B2]
.Cells(x + i, 2) = [D2]
.Cells(x + i, 3) = [E2]
.Cells(x + i, 4) = Cells(i + 4, 1)
.Cells(x + i, 5) = Cells(i + 4, 2)
.Cells(x + i, 6) = Cells(i + 4, 3)
.Cells(x + i, 7) = Cells(i + 4, 4)
.Cells(x + i, 8) = Cells(i + 4, 5)
.Cells(x + i, 9) = [B8]
.Cells(x + i, 10) = [E8]
End If
Next
End With
s = Range("e2")
Range("e2") = Left(s, 2) & Right("0000" & Right(s, 4) + 1, 4)
MsgBox "打印并保存完毕"
End Sub


当商品名称为空值时,如何不输出任何值
Sheets("票据打印").Select
ActiveWindow.SelectedSheets.PrintOut
With Sheets("记录")
x = .Range("a65536").End(xlUp).Row + 1
For i = 0 To 5
If .Cells(i + 4, 1) <> "" Then
.Cells(x + i, 1) = [B2]
.Cells(x + i, 2) = [D2]
.Cells(x + i, 3) = [E2]
.Cells(x + i, 4) = Cells(i + 4, 1)
.Cells(x + i, 5) = Cells(i + 4, 2)
.Cells(x + i, 6) = Cells(i + 4, 3)
.Cells(x + i, 7) = Cells(i + 4, 4)
.Cells(x + i, 8) = Cells(i + 4, 5)
.Cells(x + i, 9) = [B8]
.Cells(x + i, 10) = [E8]
End If
Next
End With
s = Range("e2")
Range("e2") = Left(s, 2) & Right("0000" & Right(s, 4) + 1, 4)
MsgBox "打印并保存完毕"
End Sub


当商品名称为空值时,如何不输出任何值