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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
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

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,367
Office Version
  1. 365
Platform
  1. Windows
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,195,992
Messages
6,012,741
Members
441,724
Latest member
Aalbid

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
Top