Help For Option Button for Excel VBA Form

excelway

New Member
Joined
Jan 30, 2015
Messages
13
I have an excel User form containing the following objects.
1. 2 option buttons (Name of Option Button1=Admin, Name of Option Button2=Operation)
2. 1 List Box
3. 2 List on Excel Sheet Name Admin and Operation
I want that if someone select Option Button1(Admin) the List Box Show only the Admin List and similarly if someone select Option Button2(Operation),list box show only Operation List
In my mind I have the following code but it is not working

Code:
If OptionButton5 = True Then
ListBox1.RowSource = "Admin"
Else if OptionButton6 = True then
ListBox1.RowSource = "operation"
End if
Also please let me know that where to put this code.

Thanks
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try this:

Code:
Private Sub Admin_Click()
ListBox1.RowSource = "Admin"
End Sub

Private Sub Operation_Click()
ListBox1.RowSource = "Operation"
End Sub

Double click the option button and paste the code in the button
 
Last edited:
Upvote 0

Forum statistics

Threads
1,196,047
Messages
6,013,084
Members
441,747
Latest member
darkman77

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