|
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- If Not Application.Intersect([i2:am2], Target) Is Nothing Then
- l = Target.Column
- h = Target.Row
- Dim bomrr, mrprr
- bomrr = Sheets("BOM").Range("a23:d42")
- mrprr = Sheets("MRP").Range("a4:ag13")
- With Sheets("物料需求")
- r = .Range("a65536").End(xlUp).Row
- For i = 3 To r Step 3
- wlrr = Sheets("物料需求").Cells(i, l)
- xh = .Cells(i, 1).Value
- wlrr = 0
- For j = 1 To UBound(mrprr)
- If mrprr(j, l - 5) <> 0 Then
- For m = 1 To UBound(bomrr)
- If bomrr(m, 3) = mrprr(j, 1) And xh = bomrr(m, 1) Then
- wlrr = wlrr + bomrr(m, 4) * mrprr(j, l - 5)
- End If
- Next
- End If
- Next
- .Cells(i, l) = wlrr
-
- Next
- End With
- End If
- End Sub
复制代码
复制到”物料需求”工作表,点击日期,自动生成物料需求。 |
|