PDA

View Full Version : [SOLVED] UF ComboBox Populate from Sheet



Emoncada
08-01-2014, 06:09 AM
I have a userform with Radio buttons. I want to be able to click on a radio button then have it populate a combobox based on what radio button is selected.
So if

OptButtonHP.value = True Then

cmbboxModel.additem = sheet("Lists").Range("A2:A"), Cells(Row.Count, "A").End(xlUp)


If another radiobutton is selected that range would change to ("B2:B")....

Any assistance would be great.

Thanks,

p45cal
08-01-2014, 03:43 PM
probably something along the lines of:
Private Sub OptButtonHP_Change()
With Sheets("Lists")
If OptButtonHP Then
cmbboxModel.List = .Range("A2", .Cells(.Rows.Count, "A").End(xlUp)).Value
Else
cmbboxModel.List = .Range("B2", .Cells(.Rows.Count, "B").End(xlUp)).Value
End If
End With
End Sub
or:
Private Sub OptButtonHP_Change()
With Sheets("Lists")
If OptButtonHP Then
cmbboxModel.RowSource = .Range("A2", .Cells(.Rows.Count, "A").End(xlUp)).Address(external:=True)
Else
cmbboxModel.RowSource = .Range("B2", .Cells(.Rows.Count, "B").End(xlUp)).Address(external:=True)
End If
End With
End Sub

snb
08-03-2014, 12:27 PM
Private Sub OptButtonHP_Change()
cmbboxModel.List = Sheets("Lists").columns(1).specialcells(2).offset(1).specialcells(2).value
End Sub

Private Sub OptButtonHQ_Change()
cmbboxModel.List = Sheets("Lists").columns(2).specialcells(2).offset(1).specialcells(2).value
End Sub

Emoncada
08-04-2014, 10:15 AM
That worked. Thanks