combobox

M

Mark

I am using Excel 97, I have an array in vba for the
dropdown.

If a user types something in the combobox which isn't in
the array, is there a way to check the array and if it
isn't listed to continue and change the entry of another
cell say?

Can someone help please?


Mark
 
P

papou

Hello Mark
Not too sure I understand!
If you wish to have an additionnal element in your combo and your source
range when user types a non-matching value then you could do something like
this (please amend accordingly and note that I am referencing the sheet's
codename and items are added with the combobox.Additem method in the
Userform_Initialize event):
Private Sub ComboBox1_AfterUpdate()
If Not ComboBox1.MatchFound Then
If MsgBox("Add new item " & ComboBox1.Value, vbYesNo + vbQuestion, _
"Not in list") = vbYes Then
ComboBox1.AddItem ComboBox1.Value
Feuil1.Range("A65536").End(xlUp)(2).Value = ComboBox1.Value
End If
End If
End Sub

HTH
Cordially
Pascal
 
Top