Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Update Combobox with New Data
this isn't perfect but should give you a start you may add: sorting, checking that item is not in list etc etc. Option Explicit Dim prEvent As Boolean Private Sub cboBox1_change() If prEvent Then Exit Sub If cboBox1.ListIndex = cboBox1.ListCount - 1 Then txtBox1.SetFocus End If End Sub Private Sub txtBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If prEvent Then Exit Sub Else prEvent = True If txtBox1.Text < "" Then If MsgBox("Add this to combo?", vbYesNo) = vbYes Then cboBox1.AddItem txtBox1.Text, cboBox1.ListCount - 1 End If txtBox1.Text = "" End If cboBox1.ListIndex = cboBox1.ListCount - 2 cboBox1.SetFocus prEvent = False End Sub Private Sub UserForm_Initialize() prEvent = True With Me.cboBox1 'some props that should be set in design .MatchEntry = fmMatchEntryFirstLetter .MatchRequired = True .Style = fmStyleDropDownList 'add a few items .AddItem "Choice1" .AddItem "Choice2" .AddItem "AddNewItem" .ListIndex = 0 End With prEvent = False End Sub keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool "?B?VHJveQ==?=" wrote: Can anyone help me with this problem? Userform with a ComboBox: Top line in list is "Add New Data" When line is selected, another Userform is opened, it has: A label asking for new data A Textbox A Commandbutton When the Commandbutton is pressed: The value of the Textbox is added to the Combobox. The value of the Combobox is the new data added. Is all this possible? Thanks... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need to update a ComboBox when selecting a sheet | Excel Worksheet Functions | |||
combobox update | Excel Programming | |||
Combobox update | Excel Programming | |||
Combobox: Selecting values from a row and place in combi box plus update | Excel Programming | |||
Dynamic update on ComboBox | Excel Programming |