User form: Option Button to Fill data range of combobox

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
I am attempting to create a user form. :eek: :eek:
I have created 8 option boxes on my user form.
I have a combobox created on my user form.
Can I add code the when I select option1, it would give me the data from my "Sheet1('sheet1's name is RB) Column C" into my combo box.
Then if I select option2 Sheet2('Sheet2's name is WR) Column C would enter into the combobox.
I have code written that once I choose the item in the combo box, it then places the info into the active cell.

I already thought about making a master list with all the data from all the sheets, but I really would rather them be separate.

Thank you, :biggrin: :biggrin:
Michael
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Needs a bit of code for each optionbutton and a shared routine ...
Code:
Dim SheetName As String         ' shared variable
'----------------------------------------------------------
Private Sub OptionButton1_Click()
    SheetName = "RB"
    FillCombo
End Sub
'----------------------------------------------------------
Private Sub OptionButton2_Click()
    SheetName = "WR"
    FillCombo
End Sub
'----------------------------------------------------------
Private Sub FillCombo()
    Dim ws As Worksheet
    Dim ToRow As Long
    '------------------------------------------------------
    '- initialise variables
    Set ws = Worksheets(SheetName)
    ToRow = 1
    '------------------------------------------------------
    '- clear combo
    ComboBox1.Clear
    '------------------------------------------------------
    '- write new values
    While ws.Cells(ToRow, "C").Value <> ""
        ComboBox1.AddItem ws.Cells(ToRow, "C").Value
        ToRow = ToRow + 1
    Wend
End Sub
'----------------------------------------------------------
 
Upvote 0
Michael

Did you ever try the suggestion i made in your other thread?

ie using a listbox and combobox
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,443
Members
448,898
Latest member
drewmorgan128

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top