I created a userForm in the form of a checklist with CheckBoxes to check, I would like to make it mandatory to check one of the boxes of each line before having access to a combobox grouping the different modules of the macro (each module has a vba code) then I want to add a CommandButton that will launch the chosen module.
I know it must be a mess for the VBA gods, I'm not a programmer and I don't know if it's possible?
PS: The macro is launched by a drawing software (Solidworks), that's why the checklist is in the userform and not in an excel sheet.
Thank you for your help, I changed my userForm with your code for the checklist that's good, on the other hand in the drop-down list, I would have liked the list of the 4 modules below (see image test.jpg) and depending on the module chosen, launch the module macro.
And if you really want to list your modules by code then you need to be able to do something like:
Private Sub UserForm_Activate()
Dim vbProj As VBProject
Dim vbComp As VBComponent
Dim i As Integer
Dim maMacro As String
maMacro = "MacroUserForm" 'à remplacer par le nom de la macro
For Each vbProj In Application.VBE.VBProjects
i = 1
If vbProj.Name = maMacro Then
For Each vbComp In vbProj.VBComponents
If vbProj.VBComponents.Item(i).Type = 1 Then
ComboBox1.AddItem vbProj.VBComponents.Item(i).Name
End If
i = i + 1
Next
End If
Next
End Sub
Be careful, don't forget to put "Microsoft Visual Basic for Applications Extensibility" in Tools/References.
After a few modifications, the userform works, it shows me all the modules in the drop-down list.
Small problem see attached file:
1- From the start my drop-down list is accessible with the choice of modules, it would be better if it is grayed out as long as the boxes are not checked
2- The button does not launch the module chosen from the drop-down list