I would appreciate some assistance to the following problem. The below code populates 10 checkboxes on the form. Clicking on one of them must show up the name of a clicked checkbox however this doesn't happen.
Is there anything wrong with the code?
Assistance would be greatly appreciated.
Option Explicit Dim chkArray() As New clsCheck Private Sub Test() Dim NewCheckBox As MSForms.CheckBox Dim NewLable As MSForms.Label Dim NewTextBox As MSForms.TextBox Dim PartType, TempForm Dim X As Integer Application.VBE.MainWindow.Visible = False Set TempForm = ThisWorkbook.VBProject.VBComponents.Add(3) 'Create the User Form With TempForm .Properties("Caption") = "Test" .Properties("Width") = 450 .Properties("Height") = 300 End With For X = 1 To 10 Set NewCheckBox = TempForm.designer.Controls.Add("Forms.checkbox.1") With NewCheckBox .Name = "NewCheckBox" & X + 1 .Caption = X .Value = False .Top = 20 + (12 * X) .Left = 250 .Width = 100 End With ReDim Preserve chkArray(1 To X) Set chkArray(X).myCheckBox = NewCheckBox Next X 'Show the form VBA.UserForms.Add(TempForm.Name).Show End Sub