Sub dj_save()
Dim r, r1, r2 As Long
r = 3: r2 = 3
With Sheets("出库打印模板")
Do While .Cells(r + 1, "B") <> ""
r = r + 1
If .Cells(r, "F") <> "" Then r2 = r2 + 1
If r = 24 Then Exit Do
Loop
End With
If r = 3 Or r <> r2 Then
MsgBox "单据主要区域未填齐!"
Exit Sub
End If
With Sheets("全部出货明细")
r1 = .Range("b65536").End(xlUp).Row + 1
.Cells(r1, 2).Resize(r - 3, 1) = Range("B2")
.Cells(r1, 1).Resize(r - 3, 1) = Cells(4, 1).Resize(r - 3, 1).Value
For I = 3 To 8
.Cells(r1, I).Resize(r - 3, 1) = Cells(4, I - 1).Resize(r - 3, 1).Value
Next
.Cells(r1, 9).Resize(r - 3, 1) = Range("E2")
MsgBox "单据保存成功!"
End With
Cells(4, "B").Resize(21, 1).ClearContents
Cells(4, "E").Resize(21, 2).ClearContents
End Sub