Hi,
I have a userform that I am creating, I wanted to know if I am able to programmatically add buttons to the actual userform.
I am having a lot of trouble with these buttons as they assign random numbers to buttons and I am losing count and organization.
Lets say I want to add 20 Command buttons on to my userform.
I also want to have control over the number that the command button starts at
lets say i wanted to generate 20 command buttons , but the number starts at command button 60
so I would have
command button 60,
command button 61....etc
these being added to the userform canvas.
the code does not work below
Code:
Sub AddButtons()
Dim ButtonCount As Integer
Dim ctl As Control
' Create the Button objects
ButtonCount = 0
With ThisDocument.VBProject.vbComponents("UserForm1").Designer
For Each ctl In UserForm1.Controls
ButtonCount = ButtonCount + 1
ReDim Preserve Buttons(1 To ButtonCount)
Set Buttons(ButtonCount).ButtonGroup = ctl
End If
End If
Next ctl
End Sub
I have researched on google and nothing remotely to do with this comes up. I have seen ideas to generate temporary on the fly userforms , but I want these buttons to be added to the actual user form canvas.
Is this possible at all?
Really struggling with these buttons and form components.
thank you for any tips
dan