我需要一个能够执行以下操作的功能来跟踪Excel 2007中的“现有”库存:
我有3张:“库存”,“现有”和“销售”,列名相同: A1 =样式#B1 =小C1 =中D1 =大E1 = X-大 我在“库存”和“现有”中有相同数量的行,但在“销售”中总是不同。
我想要的是有一个功能来执行此操作:
任何帮助将不胜感激。
答案 0 :(得分:0)
If Sheets("Inventory").Cells(Rows.Count,"A").End(xlup).Row <> Sheets("On Hand").Cells(Rows.Count,"A").End(xlup).Row Then
For k = 1 to Sheets("Inventory").Cells(Rows.Count,"A").End(xlup).Row
Sheets("On Hand").Range("A" & k & ":E" & k)=Sheets("Inventory").Range("A" & k & ":E" & k)
Next k
End If
For i=1 to Sheets("Sales").Cells(Rows.Count,"A").End(xlup).Row
For j=1 to Sheets("On Hand").Cells(Rows.Count,"A").End(xlup).Row
If Sheets("Sales").Cells(i, "A") = Sheets("On Hand").Cells(j,"A") Then
If Sheets("Sales").Cells(i, "B")<>"" then Sheets("On Hand").Cells(j,"B") = Sheets("On Hand").Cells(j,"B") - 1
If Sheets("Sales").Cells(i, "C")<>"" then Sheets("On Hand").Cells(j,"C") = Sheets("On Hand").Cells(j,"C") - 1
If Sheets("Sales").Cells(i, "D")<>"" then Sheets("On Hand").Cells(j,"D") = Sheets("On Hand").Cells(j,"D") - 1
If Sheets("Sales").Cells(i, "E")<>"" then Sheets("On Hand").Cells(j,"E") = Sheets("On Hand").Cells(j,"E") - 1
End If
Next j
Next I
如果这篇文章有用,请标记为向上按钮。
答案 1 :(得分:0)
你可以从1号开始..在你的工作表“库存”
Private Sub Worksheet_Change(ByVal Target As Range)
Sheets("OnHand").Cells(Target.Row, Target.Column) = Target.Value
End Sub