|
楼主 |
发表于 2016-8-7 16:56
|
显示全部楼层
代码如下:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Target.Row > Cells(Rows.Count, 1).End(3).Row Then Exit Sub
If Target.Column <> 2 Then Exit Sub
If Target.Count <> 1 Then Exit Sub
If Target.Value = "" Then Exit Sub
Set rng = Sheet2.Columns("a").Find(Target.Offset(0, -1))
If rng.Offset(0, 1).Value < Target.Value Then
MsgBox "库存不足!" & Chr(13) & "出库数量大于当前库存数量!"
Target.ClearContents
Else
rng.Offset(0, 1) = rng.Offset(0, 1) - Target.Value
End If
End Sub |
|