vesoredordead
New Member
- Joined
- Nov 3, 2017
- Messages
- 5
Hello friends,
I am trying to create a UserForm containing a number CheckBoxes for every name in a list. The tricky (for me) part is that the list of names is not constant and could vary between 0 and many names every day. So because of that I am adding the checkboxes to the UForm dynamically with the code bellow. The user should then check/uncheck the Names' boxes and depending on the user input the program continiues.
My problem is that after the interaction between the user and the UForm all the CheckBox.Values remain the same as originally initialized, regardless of the user input. I am pretty sure that the problem is due to the "dynamic" number of checkboxes because I tried the UForm with predefined checkboxes and it works fine. This doesn't help me, however...
Please, any advice would be appreciated!
Thanks!
I am trying to create a UserForm containing a number CheckBoxes for every name in a list. The tricky (for me) part is that the list of names is not constant and could vary between 0 and many names every day. So because of that I am adding the checkboxes to the UForm dynamically with the code bellow. The user should then check/uncheck the Names' boxes and depending on the user input the program continiues.
My problem is that after the interaction between the user and the UForm all the CheckBox.Values remain the same as originally initialized, regardless of the user input. I am pretty sure that the problem is due to the "dynamic" number of checkboxes because I tried the UForm with predefined checkboxes and it works fine. This doesn't help me, however...
Please, any advice would be appreciated!
Thanks!
VBA Code:
Dim ChkBx As MSForms.CheckBox
'using public variables from a separate module
Private Sub UserForm_Initialize()
'add checkbox for all relevant parties
i = 0
For i = 1 To j
'A CheckBox for every Name
Set ChkBx = Me.FR_List.Controls.Add("Forms.CheckBox.1", "ChkBox_" & i)
ChkBx.Caption = People(i) & Chr(10) & "No:" & IDList(i)
ChkBx.GroupName = "Congrats"
ChkBx.Left = 8
ChkBx.Top = 12 + ((i - 1) * 35)
If Days(i) > 0 Then
ChkBx.Value = False
Else
ChkBx.Value = True
End If
ChkBx.Width = 150
ChkBx.AutoSize = True
Next
End Sub