|
具体见附件。
弄了二天,实在是太绕脑袋了,脑袋现在全是浆糊,给绕进去了。
查了论坛很多先进先出的代码,都不涉及到多个料号,我这里是有很多重不同的料号,
先进先出,不考虑日期因素。
谁帮我检查一下代码,该怎么改?多谢了。
Book2.zip
(19.87 KB, 下载次数: 15)
- Option Explicit
- Private Sub CommandButton1_Click()
- Dim item, xx, i As Integer
- Dim inputqty1, inputqty2, inputamt1, inputamt2, outputqty, outputqtyttl, outputamtttl As Long
- Range("j2:j65536").ClearContents
- 10: i = 2
- xx = 2
- inputqty1 = 0
- inputqty2 = 0
- inputamt1 = 0
- inputamt2 = 0
- outputqty = 0
- outputqtyttl = 0
- outputamtttl = 0
- 11: If Len(Cells(i, 10)) > 0 Then
- i = i + 1
- If i > Range("i65536").End(xlUp).Row Then
- Exit Sub
- End If
- GoTo 11
- End If
- 20: item = Cells(i, 5)
- 30: If Cells(i, 5) <> item Then
- i = i + 1
- If i > Range("i65536").End(xlUp).Row Then
- GoTo 10
- End If
- GoTo 30
- End If
- outputqty = Cells(i, 9)
- outputqtyttl = outputqtyttl + outputqty
- 50: inputqty2 = inputqty1
- inputamt2 = inputamt1
- 60: With Sheets("INPUT")
- If .Cells(xx, 4) = item Then
- inputqty1 = inputqty1 + .Cells(xx, 8)
- inputamt1 = inputamt1 + .Cells(xx, 9)
- Else
- xx = xx + 1
- If xx > .Range("H65536").End(xlUp).Row Then
- i = i + 1
- GoTo 30
- End If
- GoTo 60
- End If
- If outputqtyttl <= inputqty1 Then
- Cells(i, 10) = (1 - (inputqty1 - outputqtyttl) / .Cells(xx, 8)) * .Cells(xx, 9) + inputamt2 - outputamtttl
- outputamtttl = outputamtttl + Cells(i, 10) 'actually cells(i,10)=0 currently
- i = i + 1
- xx = xx + 1
- If i > Range("i65536").End(xlUp).Row Then
- GoTo 10
- End If
- GoTo 30
- Else
- xx = xx + 1
- GoTo 50
- End If
- End With
- GoTo 10
- End Sub
复制代码
|
|