Sub 入库单录入() With Sheets("首页") '写入订单汇总,先从第一单查起,如果本批数量超过第一单数量,余额继续查找写入下一单 m = .Range("H8") bolI = True For i = 1 To Sheets("订单汇总").Range("C65536").End(xlUp).Row If Sheets("订单汇总").Cells(i, "L") = .Range("H14") Then bolI = False If Sheets("订单汇总").Cells(i, "C") = .Range("E6") And Sheets("订单汇总").Cells(i, "B") = .Range("H4") Then '型号及牌号是否相同 If Sheets("订单汇总").Cells(i, "E") <> Sheets("订单汇总").Cells(i, "H") Then '数量是否已经相同 If Sheets("订单汇总").Cells(i, "L") = .Range("H14") And Sheets("订单汇总").Cells(i, "B") = .Range("H4") Then '型号及牌号是否相同 j = Sheets("订单汇总").Cells(i, "E") - Sheets("订单汇总").Cells(i, "H") '变量值等于已经到货数量与订货数量的差额 If m > j Then Sheets("订单汇总").Cells(i, "H") = Sheets("订单汇总").Cells(i, "H") + j '到货数量补足差额 Sheets("订单汇总").Cells(i, "G") = .Range("E4") '更新到货日期 m = m - j ElseIf m <= j Then Sheets("订单汇总").Cells(i, "H") = Sheets("订单汇总").Cells(i, "H") + m '到货数量补足差额 Sheets("订单汇总").Cells(i, "G") = .Range("E4") '更新到货日期 Exit For End If End If End If Next 到底那里出错啦,为什么会编译错误Nexti没有For
|