1.EXCEL 根据物料关系BOM表和物料需求表,物料从源码编译tensorflow用VB怎么写代码在另一张空白表中计算下阶物料的需求数量,谢谢
EXCEL 根据物料关系BOM表和物料需求表,用VB怎么写代码在另一张空白表中计算下阶物料的需求数量,谢谢
Sub xx()
i = 2
j = 2
Do While Sheets("BOM").Cells(i, 3) <> ""
x = True
For k = 2 To i - 1
If Sheets("BOM").Cells(i, 3) = Sheets("BOM").Cells(k, 3) Then
x = False
Exit For
End If
Next
If x Then
Sheets("计算").Cells(j, 1) = Sheets("BOM").Cells(i, 3)
s = 0
For k = i To Sheets("BOM").Cells(1, 4).End(xlDown).Row
If Sheets("BOM").Cells(i, 3) = Sheets("BOM").Cells(k, 3) Then
For l = 2 To Sheets("需求").Cells(1, 1).End(xlDown).Row
If Sheets("需求").Cells(l, 1) = Sheets("BOM").Cells(k, 1) Then
s = s + Sheets("需求").Cells(l, 2) * Sheets("BOM").Cells(k, 4)
Exit For
End If
Next
End If
Next
Sheets("计算").Cells(j, 2) = s
j = j + 1
End If
i = i + 1
Loop
End Sub