|
这么简单的程序让你描述的这么复杂,我两分钟就搞定了,亲测可以用,而且比你想的还要方便。
Sub Woshinibaba()
Application.EnableEvents = True '允许触发连锁事件
End Sub
Private Sub CommandButton1_Click()
Application.EnableEvents = True '允许触发连锁事件
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$1" Then
Exit Sub
Else
Dim Arr
Dim Sous
Dim Hangh
Dim Jieg
Jieg = 0
Sous = Range("A1")
For i = 1 To Sheets.Count
If Sheets(i).Name <> "Sheet2" Then
Arr = Sheets(i).UsedRange
Hangh = Sheets(i).Range("a65536").End(xlUp).Row
For j = 2 To Hangh
If Arr(j, 1) = Sous Then
Sheets(i).Cells(j, 3) = Arr(j, 3) + 1
Jieg = 1
GoTo chaxunjieguo
End If
Next
End If
Next
End If
chaxunjieguo:
If Jieg = 0 Then
MsgBox ("未找到该商品,请维护基础数据")
End If
Application.EnableEvents = False '允许触发连锁事件
Target.Value = ""
Application.EnableEvents = True '允许触发连锁事件
Sheets("Sheet2").Activate
Sheets("Sheet2").Cells(1, 1).Select
End Sub
|
|