Change TabIndex on Userform Option Buttons

AMAS

Active Member
Joined
Apr 11, 2010
Messages
472
Hi,

I have searched and can't seem to find an answer to this problem. I have a userform with Option Buttons. I have them all initialized as deactivated except for one at a time as the user performs certain tasks (e.g. Create a new worksheet with the name "database"). Once each task is completed, the previously activated option button becomes deactivated and another option button becomes activated. That works fine. My problem now is that I can't change the default tab index settings to put the black dot next to the activated option button:

This doesn't seem to work:

Code:
If Sheets("Database").Range("A1") <> vbNull Then
     Controls("OptionButton1").Enabled = False
     Controls("OptionButton1").TabIndex = 1 
     
     Controls("OptionButton2").Enabled = True
     Controls("OptionButton2").TabIndex = 0
End If

Any thoughts?

AMAS
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I don't understand: "put the black dot next to the activated option button" (rather than in it).
Do you mean have it as if that option is selected?
If so:
Controls("OptionButton2") = True
will do it.
Tabindex only decides in which order controls get the focus as the tab key is pressed repeatedly on the keyboard.
 
Upvote 0
Sorry about my poor explanation. You are correct. I did mean inside of it and your solution worked perfectly.

Thank you so much. I was overthinking the problem.

AMAS
 
Upvote 0

Forum statistics

Threads
1,224,266
Messages
6,177,540
Members
452,782
Latest member
ZCapitao

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