Forms: Listbox question

teebruin

New Member
Joined
Mar 28, 2002
Messages
38
I'm trying to design a form. What I would like to do is have 2 option buttons and a listbox. I want to populate the listbox based upon which option button is selected. If they choose option 1, I want to show one set of data in the listbox, but if they choose option 2, I want to show a different set of data.

Can someone get me started on how to accomplish this?

Thanks in advance for any help.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi teebruin,

Assuming that you want to fill your listbox from two different worksheet ranges, you can simply use the optionbuttons' click events to reassign the RowSource property of the Listbox:

Private Sub OptionButton1_Click()
ListBox1.RowSource = "a1:a10"
End Sub

Private Sub OptionButton2_Click()
ListBox1.RowSource = "b1:b10"
End Sub
 
Upvote 0
Thank you very much. This is exactly what I was looking for. I was focused on doing something to the listbox, and didn't even think about the option buttons.

Again, thanks.
 
Upvote 0

Forum statistics

Threads
1,213,529
Messages
6,114,155
Members
448,554
Latest member
Gleisner2

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