Add checkboxes in a User form in VBA

Hello 

I would like to add via a macro a number of checkboxes that can be variable from one configuration to another.

The problem is that I can't add even a checkbox in a userform.

Is it possible to do so if so, how I beg you?

Thank you in advance 

Hello

First of all, you need to display the tools dialog box to be able to add checkboxes to a userform.

To add them dynamically, you have to play with loops in vba or, if the number of checkboxes is known in advance, play with their visibility and resize the userform window as you go.

1 Like

Hello, thank you for your answer

I want to add them via lines of code because I don't know the number of checkboxes to create before launching my macro (I can go from 3 to more than 100). That's why I wanted to know a way to open only VBA code online

Hello

You can check out this link: Dynamically create CheckBox + OnAction? - Excel macros and VBA (developpez.net)

1 Like

Good evening
Attached is a rudimentary macro that inserts a CheckBox into a frame of a sheet of paper with each click of a button.
It uses the Add method in the frame's Controls collection to add the CheckBox component, which is stored in an array that is incremented as you create.

The page that seems to me the most self-explanatory of the help for Microsoft Forms is obtained by searching for the keyword Controls, then Add...

Kind regards.


insertcheckbox.png
insertcheckbox.swp