title: Alert user for duplicate entry to a textbox on userform
body: <p>I have a userform with a textbox for entering the product name and I would like to alert the user, when a duplicate name is entered. The Values entered in this column will get stored in column A and my column A will have values like Kat-1,kat-2,Amp-0,Pji-4 etc. I tried the code below but it is giving me an duplicate entry message when a 'k' is entered. Essentially, I would like it to check completely for 'Kat-1' and then display a duplicate entry message.   </p>
  
  <pre><code>  Private Sub txt_BPName_Change()
  Dim cel As Variant
  Dim myrange As Range
  Set myrange = Worksheets("Sheet1").Range("A2:A" &amp; Cells(Rows.Count, "A").End(xlUp).row)
  'myrange.Interior.ColorIndex = xlNone
  
  For Each cel In myrange
    If Application.WorksheetFunction.CountIf(myrange, cel) &gt; 1 Then
    MsgBox ("Duplicate Entry")
  Exit For
    End If
  Next
  
  Dim i As Long
  Dim Count As Long
  Do
   For i = 1 To Len(txt_BPName.Text)
     Select Case Asc(Mid(txt_BPName.Text, i, 1))
       Case 45, 48 To 57, 65 To 90, 97 To 122
       'Cells(Row, 1).Select
       ActiveCell.Formula = txt_BPName.Text
       Count = 0
       Case Else
       MsgBox ("Invalid Entry")
   Exit For
       txt_BPName.SetFocus
       Count = 1
  End Select
  Next
  Loop While Count &lt;&gt; 0
  
  End Sub
  </code></pre>