Good Evening,
I have two comboboxes that I am trying to populate from an excel sheet and I could use some help getting the second one to work.
The first box is a "Make" box where the user selects the make of, say - a car. From there, it populates the second "Model" box based on the models that that Maker provides.
I have this set up in an excel sheet where each column is dedicated to the Make - so, the first row is all Manufacturers (For cars, Ford, Chevy, Dodge, Buick, etc). Below each manufacturer, I have all of the cars they make listed. My goal is that when a user selects the Make, the Model box automatically populates with the content in the column below the manufacturer name.
I have successfully made the Make box autopopulate on the "Inititialize" command but I am having trouble getting the model box to populate when the make is selected. My code is below.
Private Sub Userform_Initialize()
'Populates Make List
column_review = 0
Dim Model As Worksheet
Set Model = Sheets("MakeModel")
Do
DoEvents
column_review = column_review + 1
item_in_review = Model.Cells(1, column_review)
If Len(item_in_review) > 0 Then cboMake.AddItem (item_in_review)
Loop Until item_in_review = ""
End Sub
This code works^ to populate the make box. Below is my poor attempt at getting the model box to populate. I know I need to get column_review to equal the column of the make.
Private Sub cboMake_Change()
''Populates Model list based on "Make" Selection
make_review = 1
' Dim Makeselect As String
Set Makeselect = cboMake.Text
' Dim Make As Worksheet
' Set Make = Sheets("MakeModel")
Do
DoEvents
make_review = make_review + 1
item_in_review = Model.Cells(1, column_review)
If Len(item_in_review) > 0 Then cboMake.AddItem (item_in_review)
Loop Until item_in_review = ""
End Sub
Any help is appreciated. Thanks!
I have two comboboxes that I am trying to populate from an excel sheet and I could use some help getting the second one to work.
The first box is a "Make" box where the user selects the make of, say - a car. From there, it populates the second "Model" box based on the models that that Maker provides.
I have this set up in an excel sheet where each column is dedicated to the Make - so, the first row is all Manufacturers (For cars, Ford, Chevy, Dodge, Buick, etc). Below each manufacturer, I have all of the cars they make listed. My goal is that when a user selects the Make, the Model box automatically populates with the content in the column below the manufacturer name.
I have successfully made the Make box autopopulate on the "Inititialize" command but I am having trouble getting the model box to populate when the make is selected. My code is below.
Private Sub Userform_Initialize()
'Populates Make List
column_review = 0
Dim Model As Worksheet
Set Model = Sheets("MakeModel")
Do
DoEvents
column_review = column_review + 1
item_in_review = Model.Cells(1, column_review)
If Len(item_in_review) > 0 Then cboMake.AddItem (item_in_review)
Loop Until item_in_review = ""
End Sub
This code works^ to populate the make box. Below is my poor attempt at getting the model box to populate. I know I need to get column_review to equal the column of the make.
Private Sub cboMake_Change()
''Populates Model list based on "Make" Selection
make_review = 1
' Dim Makeselect As String
Set Makeselect = cboMake.Text
' Dim Make As Worksheet
' Set Make = Sheets("MakeModel")
Do
DoEvents
make_review = make_review + 1
item_in_review = Model.Cells(1, column_review)
If Len(item_in_review) > 0 Then cboMake.AddItem (item_in_review)
Loop Until item_in_review = ""
End Sub
Any help is appreciated. Thanks!