ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dynamically updating Combobox (https://www.excelbanter.com/excel-programming/386723-dynamically-updating-combobox.html)

Darren Hill[_4_]

Dynamically updating Combobox
 
In my form, I have a combobox which includes a list of names harvested
from several worksheets and allows the user to select one.
I'd like for the combobox to operate like this:
* Allows user to pick a name from the list (preferably with match first
letter option)
* Allows user to enter a name, and once done, add that to the combobox
list and sort it.

I find that the combobox_change event keeps firing, so I end up with a
list of partial names.
If I add "Roger" to the list, i'll also end up with "r", "ro", "rog" and
"roge" in the list.

Thanks, Darren.

pierced84

Dynamically updating Combobox
 
Had the same problem today. Here is the example I used:

Private Sub ComboBox1_Change()
Dim strRange As String
If ComboBox1.ListIndex -1 Then
strRange = ComboBox1
Label2.Caption = strRange
strRange = Replace(strRange, " ", "_")
With ComboBox2
.RowSource = vbNullString
.RowSource = strRange
.ListIndex = 0
End With
Else
Label2.Caption = "Associated Items"
End If
End Sub

You have to select the first cell in a column and go to InsertNameDefine
in order to define what the name of your data is.



"Darren Hill" wrote:

In my form, I have a combobox which includes a list of names harvested
from several worksheets and allows the user to select one.
I'd like for the combobox to operate like this:
* Allows user to pick a name from the list (preferably with match first
letter option)
* Allows user to enter a name, and once done, add that to the combobox
list and sort it.

I find that the combobox_change event keeps firing, so I end up with a
list of partial names.
If I add "Roger" to the list, i'll also end up with "r", "ro", "rog" and
"roge" in the list.

Thanks, Darren.



All times are GMT +1. The time now is 12:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com