|
参与一下,,,,
做了一个领用的,入库的楼主可以参考着自己做,
- Sub 辅料表出库()
- Application.ScreenUpdating = False '//关闭屏幕刷新
- Application.DisplayAlerts = False '//关闭系统提示
- Application.EnableEvents = False '//禁止触发其他事件
- Application.StatusBar = True '关闭系统状态
-
- Dim Wk As Workbook, xWk As Workbook
- Dim MyPath$, xStr$, yStr$
- Dim x&, y&, a&, b&, c&
- Dim Arr, Brr
- Dim xBoo As Boolean
-
- xBoo = True
- For Each Wk In Workbooks
- If Wk.Name Like "2024辅材日报表.xlsx" Then
- xBoo = False
- Set xWk = Wk
- Exit For
- End If
- Next
- Set Wk = ThisWorkbook
- If xBoo Then Set xWk = Workbooks.Open(Wk.Path & "\2024辅材日报表.xlsx")
-
- With Wk.Sheets("领用")
- a = .Cells(Rows.Count, 2).End(xlUp).Row
- Arr = .Range("b4:l" & a)
- End With
- With xWk.Sheets("辅料日报")
- a = .Cells(Rows.Count, 2).End(xlUp).Row
- Brr = .Range("a5:de" & a)
- End With
-
- For x = LBound(Arr) To UBound(Arr)
- a = 0: b = 0: c = Day(Arr(x, 1)) * 3 + 15
- For y = LBound(Brr) To UBound(Brr)
- If Arr(x, 2) Like Brr(y, 4) And Arr(x, 5) Like Brr(y, 7) Then
- a = a + Brr(y, 16)
- If a > Arr(x, 7) Then
- Brr(y, c) = Arr(x, 7) - b
- Exit For
- Else
- Brr(y, c) = Brr(y, 16)
- b = b + Brr(y, 16)
- End If
- End If
- Next y
- If a < Arr(x, 7) Then MsgBox Arr(x, 2) & " 库存不足"
- Next x
-
- With xWk.Sheets("辅料日报")
- a = .Cells(Rows.Count, 2).End(xlUp).Row
- .Range("a5:de" & a) = Brr
- End With
-
- Application.StatusBar = False '//恢复系统状态条
- Application.EnableEvents = True '// 恢复触发其他事件
- Application.ScreenUpdating = True '//恢复屏幕刷新
- Application.DisplayAlerts = True '//恢复系统提示
- End Sub
复制代码
|
|