OptionBox challenge

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
Hello All,
I am having issues with how to select an optionbox when I change the content of a combobox.

If there is a way out then let me know.

Thanks.
Kelly
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi,
one way maybe:

Code:
Private Sub ComboBox1_Change()
 Me.OptionButton1.Value = CBool(Me.ComboBox1.ListIndex = 2)
End Sub

This should return true when third item in combobox list (listindex starts from 0) is selected

Dave
 
Upvote 0
Hi,
one way maybe:

Code:
Private Sub ComboBox1_Change()
 Me.OptionButton1.Value = CBool(Me.ComboBox1.ListIndex = 2)
End Sub

This should return true when third item in combobox list (listindex starts from 0) is selected

Dave

Oh okay thanks.

But it does not give what I want. I want that optionbutton on anytime I change the combobox.

Thanks again
Kelly
 
Upvote 0
try

Code:
Private Sub ComboBox1_Change()
 Me.OptionButton1.Value = CBool(Me.ComboBox1.ListIndex <> -1)
End Sub

Dave
 
Upvote 0
Yes!

Right on point. Thanks a lot
Kelly

PS. Long time @Dave
 
Upvote 0
I have one more issue here:
What if I want to use a textbox change event to switch the option button?
I tried
Code:
Private Sub TextBox1_Change()
 Me.OptionButton1.Value = CBool(Me.TextBox1.Value = "")
End Sub

But did not work
 
Upvote 0
Used the below to get what I wanted:
Code:
Private Sub TextBox1_Enter()
 Me.OptionButton1.Value = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

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