Excel prevent duplicate entries by using this method

Right click sheet tab>view code>insert this>change column 1 to suit

Private Sub Worksheet_Change _
(ByVal Target As Range)
If Target.Column <> 1 Then Exit Sub
If Application.CountIf(Columns(1), _
Target) > 1 Then MsgBox "Duplicate"
End Sub