Radio Buttons on Forms VBA

TMHill

New Member
Joined
Mar 9, 2011
Messages
2
Hi

I am adding several groups of radio buttons to a form (a page of multiple choice questions) at run-time. Each group has 3 radio buttons in it.

The complication is that there is a 'default' answer for each question, and that button should be selected initially.

So:
I add a new control with a unique name 'ButtonA1'. I then add this to groupname 'OptionButtonGroup1''
Next, I add another control with name 'ButtonB1' and set its groupname property to 'OptionButtonGroup1''
Same with 'ButtonC1', then I move on to question group 2.

I set the controlsource property of each button to an independent cell (a 3 column list of TRUE/FALSE, where only one of the three columns is set to TRUE - this is the default value I am picking up)


Everything in this process is working fine - but there is one behaviour which I am getting which is driving me NUTS! The first time I select a different answer to the default, Excel sets all values of that group to FALSE and the buttons go empty.

Plus, it doesn't matter which group I choose to click first, I get the same behaviour. Then on the next click, everything works fine! And from that point on every other group is also fine.

Anybody got any ideas or seen/solved this before?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Quick update to this - there is occassionally another weird behaviour which I believe is a symptom of the same cause (whatever that is!):

If the default is option 2, then when I click option button 1, the selection changes to option button 3. When this happens, it repeats with every group. Once its happened once, it won't happen again within that group.

I'm pretty sure its got something to do with what it thinks is its starting value - but i've even made it read that off the sheet and specifically set it, and I can't think of what else to do with it!
 
Upvote 0
I had the same problem and found that adding:

Application.Calculation = xlManual

before loading or showing the user form solved it - you would then need to turn calcululations back on afterwards.
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,875
Members
452,949
Latest member
Dupuhini

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