|
Sub 福清计划()
Application.ScreenUpdating = False
Dim ar As Variant, br As Variant, cr As Variant
Dim i As Long, r As Long, rs As Long
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("福清库存")
rs = .Cells(Rows.Count, 1).End(xlUp).Row
If rs < 4 Then MsgBox "【成品库存】工作表为空!": Exit Sub
br = .Range("a2:bv" & rs)
End With
With Sheets("福清在制品")
r = .Cells(Rows.Count, 3).End(xlUp).Row
If r < 4 Then MsgBox "【工单排程】工作表为空!": Exit Sub
ar = .Range("a2:ax" & r)
End With
With Sheets("生产计划")
ms = .Cells(Rows.Count, 1).End(xlUp).Row
If ms > 2 Then
.Range("a3:D" & ms).Borders.LineStyle = 0
.Range("c3:D" & ms) = Empty
End If
arr = .Range("a1:al" & ms)
For i = 3 To UBound(arr)
If Trim(arr(i, 1)) <> "" Then
d(Trim(arr(i, 1))) = i
End If
Next i
For i = 2 To UBound(ar)
If Trim(ar(i, 3)) <> "" Then
If Trim(ar(i, 8)) = "" Then
xh = d(Trim(ar(i, 2)))
If xh <> "" Then
arr(xh, 4) = arr(xh, 4) + ar(i, 6) '''工单数量
End If
End If
End If
Next i
'''工单排程中获不重复的料号和投料数量累计数
For i = 2 To UBound(br)
If Trim(br(i, 2)) <> "" Then
xh = d(Trim(br(i, 2)))
If xh <> "" Then
arr(xh, 3) = br(i, 9) ''期末库存
End If
End If
Next i
'''成品库存中获取期末库存
.Range("a1:D" & ms) = arr
.Range("a1:M" & ms).Borders.LineStyle = 1
End With
Application.ScreenUpdating = True
End Sub
Sub 汉中计划()
Application.ScreenUpdating = False
Dim ar As Variant, br As Variant, cr As Variant
Dim i As Long, r As Long, rs As Long
Dim F As Object
Set F = CreateObject("scripting.dictionary")
With Sheets("汉中库存")
rs = .Cells(Rows.Count, 1).End(xlUp).Row
If rs < 4 Then MsgBox "【成品库存】工作表为空!": Exit Sub
br = .Range("a2:bv" & rs)
End With
With Sheets("汉中在制品")
r = .Cells(Rows.Count, 3).End(xlUp).Row
If r < 4 Then MsgBox "【工单排程】工作表为空!": Exit Sub
ar = .Range("a2:ax" & r)
End With
With Sheets("生产计划")
ms = .Cells(Rows.Count, 1).End(xlUp).Row
If ms > 2 Then
.Range("e3:f" & ms).Borders.LineStyle = 0
.Range("e3:f" & ms) = Empty
End If
arr = .Range("a1:al" & ms)
For i = 3 To UBound(arr)
If Trim(arr(i, 1)) <> "" Then
F(Trim(arr(i, 1))) = i
End If
Next i
For i = 2 To UBound(ar)
If Trim(ar(i, 3)) <> "" Then
If Trim(ar(i, 8)) = "" Then
xh = F(Trim(ar(i, 2)))
If xh <> "" Then
arr(xh, 6) = arr(xh, 6) + ar(i, 6) '''工单数量
End If
End If
End If
Next i
'''工单排程中获不重复的料号和投料数量累计数
For i = 2 To UBound(br)
If Trim(br(i, 3)) <> "" Then
xh = F(Trim(br(i, 3)))
If xh <> "" Then
arr(xh, 5) = br(i, 9) ''期末库存
End If
End If
Next i
'''成品库存中获取期末库存
.Range("a1:f" & ms) = arr
.Range("a1:f" & ms).Borders.LineStyle = 1
End With
Application.ScreenUpdating = True
End Sub |
|