title: VBA, add compare values listbox combobox
body: <p>in a userform i have a listbox and a combobox, listbox will receive values from combobox via a button 'Add',i need to write a control to check if the values selected in combobox already exist in listbox , if it exist a beep will be played if not the value will be added. this is one of some tested codes, the control of empty values is working well but cannot add vlues or tst controls.</p>
  
  <pre><code>If etatgen.Value = vbNullString Then
      MsgBox ("Non authorized value")
      Exit Sub
  Else
  Dim i As Integer
      For i = 0 To (lstetatgen.ListCount - 1)
          If lstetatgen.List(i) = etatgen.Value Then
              Exit for
          Else
              lstetatgen.AddItem etatgen.Value
          End If
      Next
  End If
  </code></pre>
  
  <p>thanks</p>