| 
    
     |  | 学生です さん、こんばんわ。 
 Private Sub Worksheet_Change(ByVal Target As Range)
 If Not Application.Intersect(Target, Range("A1:A10")) Is Nothing Then
 With Target
 If .Count > 1 Then
 'MsgBox .Address, vbExclamation, "複数セルは対象外"
 ElseIf Target.Value = "" Then
 'MsgBox .Address, vbExclamation, "セルクリアも対象外"
 Else
 Application.EnableEvents = False
 If Application.WorksheetFunction. _
 CountIf(Range("A1:A10"), Target.Value) > 1 Then
 MsgBox Target.Value, vbInformation, "重複"
 .Select
 .ClearContents
 End If
 Application.EnableEvents = True
 End If
 End With
 End If
 End Sub
 
 A1:A10の範囲ないだけバッティングチェックをするならこんな感じです。
 他の範囲に入力されたものが、A1:A10とかぶるかどうかチェックをする場合は、
 If Not Application.Intersect(Target, Range("A1:A10")) Is Nothing Then
 と、一番下にある
 End If
 を外してください。
 
 |  |