A OptionButton that populates a value in a ListBox, Textbox or Label

ro_1991

New Member
Joined
Aug 6, 2014
Messages
6
Hi, I have been working on a UserForm. Everything is working fine except for one thing, I have multiple OptionButtons from which you will need select 1. I want a Listbox, Textbox or Label to be populated by this choice. For instance, if you pick OptionButton1 I want Label 1 to be populated automatically. If you pick OptionButton2 I want aswell Label 1 to be populated. Thanks for your help in advance! Roderik
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi, and welcome to the forum.

Assuming you have your lists stored in sheet1, something like:

Excel 2007
AB
1List1List2
2Item1Item4
3Item2Item5
4Item3Item6
Sheet1


Then set up click events for your option buttons:
Rich (BB code):
Private Sub OptionButton1_Click()
   Me.ListBox1.List = Sheets("Sheet1").Range("A2:A4").Value
End Sub


Private Sub OptionButton2_Click()
    Me.ListBox1.List = Sheets("Sheet1").Range("B2:B4").Value
End Sub

For Labels or TextBoxes just send a value:
Rich (BB code):
Private Sub OptionButton1_Click()
   Me.TextBox1.Value = "bertie"
End Sub

Hope this helps,
Bertie
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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