Iam meine Etiketten und Checkbox von Code erstellen:VBA Excel Schleife auf userform.label
i = 1
While Not Sheets("I_M_1_1PW").Cells(9 + i, 43) = "koniec"
Set theLabel = UserForm1.Controls.Add("Forms.Label.1", labelCounter, True)
With theLabel
.Caption = Sheets("I_M_1_1PW").Cells(9 + i, 43)
.Left = 10
.Width = 100
.Top = 13 * labelCounter
Debug.Print labelCounter & " " & theLabel.Caption
End With
Set chkbox = UserForm1.Controls.Add("Forms.CheckBox.1", "CheckBox_" & i)
chkbox.Caption = Sheets("I_M_1_1PW").Cells(9 + i, 44)
chkbox.Left = 100
chkbox.Width = 75
chkbox.Top = 13 * labelCounter
i = i + 1
labelCounter = labelCounter + 1
ich für aktive Kontrollkästchen von Code suchen:
For j = 1 To Granica - 1
If UserForm1.Controls("CheckBox_" & j).Value = True Then
Wynik1 = UserForm1.Controls("CheckBox_" & j).Caption + Wynik1
'* Wzorce = Wzorce + UserForm1.label(j).Caption
End If
Next
Aber in ‚* Ort bekam ich Problem kann nicht label.caption wenn iam mit UserForm1.Controls (j) .Caption seine Schleife durch alle Teile Teile von user.form nicht nur Etiketten.
Ich denke, es ist keine gute Idee, einen einfachen numerischen Wert (zB: labelCounter) als Name für Ihre Etiketten zu geben. Vielleicht erstellen Sie einen Namen wie für Checkboxen: 'UserForm1.Controls.Add (" Forms.Label.1 "," label_ "& labelCounter, True)'. –