Multiple checkboxes inside an UserForm

Oversteer

New Member
Joined
Nov 27, 2022
Messages
6
Office Version
  1. 2016
Platform
  1. Windows
Hello to all forum participants...
I created an userform (UserForm1) and inside this, I placed 20 checkboxes named from 1 to 20.
My intention is that whenever I check one random CB (setting it to true) the VBA sets all the remaining 19 CBs to False and to enabled = false, so to leave the checked one as the only one "alive".
And if I was wrong with my first choice, I can uncheck the alive checkbox back to false, with the additonal result of having the other 19 to be set back to enabled=true (and of course false).
Now, I can write down 20*19 = 380 code lines to specify each possible combination one by one, but I'm totally sure there is a much clevere and short way of doing the same task in much instructions....
Any good suggestion abut this?
Thanks a lot in advance.
Oversteer
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Before giving you code to do this I am going to suggest a clever and short way of using option buttons instead to achieve the same thing with no code. What is your overall requirement and why have you chosen to use checkboxes?
 
Upvote 0
Hello 6StringJazzer and thank you for your comment. I started immediately to evaluate alternatives, and I'm perfectly aware that the description I made is almost the perfect fit for radio buttons (one selected and all the others unchecked).
I have two issues about radio buttons: everytime I used them, I faced the issue of the shrinking dimensions (that I understood is something well known, but MS still has not fixed).
And the second issue is that first time I open the dialog box all the radio buttons must be off (but this probably a minor issue). So I choose CB just because these looks better than RB and do not create troubles. Reason: I'm involved in a local karting championship and the checkbox is to indicate the driver who scored the best lap...
 
Upvote 0

Forum statistics

Threads
1,215,019
Messages
6,122,707
Members
449,093
Latest member
Mnur

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