此代码在worksheet_change事件上执行。它会检查重复的手机号码,如果找到则显示弹出窗口并清除特定的手机号码。
If Target.Column = 1 Then
r = Target.Value
adr = Target.Address(False, False)
LastRow = ActiveSheet.Cells.SpecialCells(xlLastCell).Row
For c = 2 To LastRow
s = Sheets("Create Users").Range("A" & c).Value
If r = s And adr <> "A" & c Then
MsgBox ("Dupliacte phone numbers are not allowed.")
Target.Value = ""
End If
Next c
End If
答案 0 :(得分:0)
试试这个
Application.EnableEvents = False
Target.Value = ""
Application.EnableEvents = True