|
发表于 2022-5-2 11:36
|
显示全部楼层
本楼为最佳答案
Sub TEST()
ARR = Range("H2:Z" & Range("B65536").End(3).Row)
Workbooks.Open ("D:\库存\工厂库存表.xlsm")
With ActiveWorkbook.ActiveSheet
BRR = .Range("A2:K" & Range("A65536").End(3).Row)
For I = 1 To UBound(ARR)
If ARR(I, 19) = "是" Then
For J = 1 To UBound(BRR)
If ARR(I, 8) = BRR(J, 1) Then
If BRR(J, 11) <> "" Then
If (BRR(J, 11) - ARR(I, 1)) < 0 Then MsgBox ARR(I, 8) & "的库存量不够!": GoTo 10
BRR(J, 11) = BRR(J, 11) - ARR(I, 1)
Else
If (BRR(J, 10) - ARR(I, 1)) < 0 Then MsgBox ARR(I, 8) & "的库存量不够!": GoTo 10
BRR(J, 11) = BRR(J, 10) - ARR(I, 1)
End If
ARR(I, 19) = "已处理"
End If
Next
End If
10 Next
.Range("A2").Resize(UBound(BRR), 11) = BRR
End With
ActiveWorkbook.Close True
Range("H2").Resize(UBound(ARR), 19) = ARR
MsgBox "处理完毕!"
End Sub
|
|