|
Sub 数据录入()
Dim ar As Variant
Dim br()
With Sheets("原料粉库存记录表")
r = .Cells(Rows.Count, 2).End(xlUp).Row
ar = .Range("a1:ar" & r)
End With
ReDim br(1 To UBound(ar), 1 To 8)
For i = 3 To UBound(ar)
If Trim(ar(i, 1)) = "" Then ar(i, 1) = ar(i - 1, 1)
If Trim(ar(i, 2)) <> "" Then
n = n + 1
For j = 1 To 4
br(n, j) = ar(i, j)
Next j
br(n, 5) = ar(i, 10)
br(n, 6) = ar(i, 11)
br(n, 7) = ar(i, 43)
br(n, 8) = ar(i, 44)
End If
Next i
f = Dir(ThisWorkbook.Path & "\TJ01粉库存.xls*")
If f = "" Then MsgBox "找不到TJ01粉库存文件": End
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & f, 0)
With wb.Worksheets(1)
rs = .UsedRange.Find(What:="*", SearchDirection:=xlPrevious).Row + 1
.Cells(rs, 1).Resize(n, UBound(br, 2)) = br
End With
wb.Close True
MsgBox "ok!"
End Sub
|
|