|
我想实现通过配料表里零件简码所对应的库位和数量,到对应的表里查找匹的条码、架位、数量,其中数量需要根据需求数量来计算条码的个数,图片是模拟效果
自动消减发料库位表中发料数量,建议删除关闭自动保存代码 - Sub Macro1()
- On Error Resume Next
- Sheets("配料").Activate
- For i = 2 To Range("a65536").End(xlUp).Row
- jm = Cells(i, 1): sl = Cells(i, "i"): p = ""
- With Sheets("" & Cells(i, "h"))
- For j = 2 To .Range("a65536").End(xlUp).Row
- If .Cells(j, 4) = jm And .Cells(j, "m") > 0 Then
- p = p & .Cells(j, 3) & "," & .Cells(j, "k")
- If sl >= .Cells(j, "m") Then
- p = p & "," & .Cells(j, "m") & Chr(10)
- sl = sl - .Cells(j, "m")
- .Cells(j, "m") = 0
- Else
- p = p & "," & sl & Chr(10)
- .Cells(j, "m") = .Cells(j, "m") - sl
- Exit For
- End If
- End If
- Next
- End With
- Cells(i, "j") = p
- Next
- End Sub
复制代码
|
|