|
参与一下。。。- Private Sub Worksheet_Change(ByVal Target As Range)
- If Target.Column <> 2 Then Exit Sub
- Set d = CreateObject("Scripting.Dictionary")
- r = Me.Cells(Rows.Count, 2).End(3).Row
- arr = Me.Range("b1:b" & r)
- Application.EnableEvents = False '禁用事件处理程序
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- If Not d.exists(s) Then
- d(s) = Me.Cells(i, 2).Address
- If IsEmpty(Me.Cells(i, 4)) Then
- Me.Cells(4, 4) = Date
- End If
- Else
- Beep '发出声音报警
- MsgBox "序列号已存在,请重新输入"
- Me.Cells(i, 2).Resize(1, 3).ClearContents '清除重复数据
- End If
- Next
- Application.EnableEvents = True '启用事件处理程序
- End Sub
复制代码
|
|