ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   populating one list/combobox based on the results of another (https://www.excelbanter.com/excel-programming/318397-populating-one-list-combobox-based-results-another.html)

Tim[_39_]

populating one list/combobox based on the results of another
 
Hi,

I'd be grateful if someone could help with what i think is probably quite a
simple thing (just not as simple as me).

I have a userform with two comboboxes; the data for these come from one
data-table. combobox1 is filled with the table heading data (ie, from a
single row) and this works fine; what i can't do is populate the the second
combobox with the column of data in the data-table below the relevant header
(as chosen in the first combobox). i want the population to be programmatic
/ dynamic as the table is likely to change over time.

hope someone can help, cheers,

tim



Tim[_39_]

populating one list/combobox based on the results of another
 

"Tim" wrote in message
...
Hi,

I'd be grateful if someone could help with what i think is probably quite

a
simple thing (just not as simple as me).

I have a userform with two comboboxes; the data for these come from one
data-table. combobox1 is filled with the table heading data (ie, from a
single row) and this works fine; what i can't do is populate the the

second
combobox with the column of data in the data-table below the relevant

header
(as chosen in the first combobox). i want the population to be

programmatic
/ dynamic as the table is likely to change over time.

hope someone can help, cheers,

tim


apologies for replying to my own post - i've cobbled together something that
works (see below) - can anyone improve it, eg, i must be able to do it
without actually selecting cells? no worries if not, as i've got the thing
basically working now.

cheers

tim

Private Sub ComboBox1_AfterUpdate()

ComboBox2.Enabled = True
On Error Resume Next
Dim FindValue As String

FindValue = ComboBox1.Value
Application.Goto Reference:="rngsite"
Selection.Find(What:=FindValue, After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Select
UserForm1.ComboBox2.Clear
ActiveCell.Offset(1, 0).Select
Do Until ActiveCell.Value = ""
UserForm1.ComboBox2.AddItem ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Loop
End Sub






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

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