Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to update a ComboBox when selecting a sheet [email protected] Excel Worksheet Functions 1 October 31st 07 02:23 PM
combobox update Josh[_9_] Excel Programming 2 February 24th 04 05:22 PM
Combobox update Robert Couchman[_4_] Excel Programming 0 February 20th 04 09:13 AM
Combobox: Selecting values from a row and place in combi box plus update New user Excel Programming 2 January 22nd 04 01:46 PM
Dynamic update on ComboBox Kevin Excel Programming 4 October 14th 03 12:45 PM


All times are GMT +1. The time now is 06:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"