Sub 录入保存()
Dim Ar As Variant
Dim rn As Range
With Sheets("数据录入")
Ar = .Range("a1:j11")
cg = .Range("F14")
dh = .[j3]
End With
Dim br()
ReDim br(1 To UBound(Ar), 1 To 18)
With Sheets("进销表")
Set rn = .Columns(2).Find(dh, , , , , , 1)
If Not rn Is Nothing Then MsgBox "不能重复录入!": End
For i = 6 To UBound(Ar)
If Trim(Ar(i, 3)) <> "" Then
n = n + 1
br(n, 1) = Ar(3, 6)
br(n, 2) = Ar(3, 10)
br(n, 3) = Ar(i, 10)
For j = 3 To 6
br(n, j + 1) = Ar(i, j)
Next j
If Trim(Ar(2, 2)) = "存 货 入 库 单" Then
br(n, 8) = Ar(i, 7)
br(n, 9) = Ar(i, 9)
br(n, 13) = "入库"
br(n, 15) = cg
Else
br(n, 10) = Ar(i, 7)
br(n, 11) = Ar(i, 8)
br(n, 12) = Ar(i, 9)
br(n, 13) = "出库"
br(n, 16) = cg
End If
br(n, 14) = Ar(3, 4)
End If
Next i
If n = "" Then MsgBox "录入表为空!": End
r = .Cells(Rows.Count, 1).End(xlUp).Row + 1
.Cells(r, 1).Resize(n, 16) = br
End With
Sheets("数据录入").Range("C6:J11").ClearContents
MsgBox "ok!"
End Sub
|