Hallo!
Also ich würde die Werte in einem Array eingeben (oder mit einer Schleife einlesen lassen, wenn die noch wo erfasst sind) und dann in deiner for Schleife darauf beziehen. Sollte so aussehen. Gruß Matthias
Private Sub CommandButton1_Click()
Dim zeile As Integer
Dim CB As CheckBox
Dim cntrl As Control
Dim CheckBoxAnzahlIP As Integer
Dim i As Integer
Dim Zwischenspeicher As String
'ist neu
Dim werte
werte = Array("Rohteil Kurbelgehäuse Sandguss Normal", _
"Rohteil Kurbelgehäuse Sandguss Stegmess", "Rohteil Kurbelgehäuse Sandguss Vollvermessen", _
"Rohteil Kurbelgehäuse Sandguss", "Rohteil Kurbelgehäuse Sandguss", "Rohteil Kurbelgehäuse Sandguss", _
"Rohteil Zylinderkopf Sandguss Normal", "Rohteil Zylinderkopf Sandguss + AV-Messstellen", _
"Rohteil Zylinderkopf Sandguss Indiziert", "Rohteil Zylinderkopf Sandguss Indiziert+AV-Messstellen", _
"Rohteil Zylinderkopf Sandguss Endoskopie", "Rohteil Zylinderkopf Sandguss Vollvermessen", _
"Rohteil Zylinderkopf Sandguss", "Rohteil Zylinderkopf Sandguss", "Rohteil Zylinderkopf Sandguss", _
"Rohteil Zylinderkopf Sandguss", "Rohteil Zylinderkopf Sandguss", "Rohteil Zylinderkopf Sandguss", _
"Rohteil Kurbelwelle Sandguss Normal", "Rohteil Kurbelwelle Sandguss Vollvermessen", _
"Rohteil Kurbelwelle Sandguss", "Rohteil Kurbelwelle Sandguss", "Rohteil Pleuel Sandguss Normal", _
"Rohteil Pleuel Sandguss Vollvermessen", "Rohteil Pleuel Sandguss", "Rohteil Pleuel Sandguss", _
"Rohteil Kurbelgehäuse Kokille Normal", "Rohteil Kurbelgehäuse Kokille Stegmess", _
"Rohteil Kurbelgehäuse Kokille Vollvermessen", "Rohteil Kurbelgehäuse Kokille", _
"Rohteil Kurbelgehäuse Kokille", "Rohteil Kurbelgehäuse Kokille", "Rohteil Zylinderkopf Kokille Normal", _
"Rohteil Zylinderkopf Kokille+AV-Messstellen", "Rohteil Zylinderkopf Kokille Indiziert", _
"Rohteil Zylinderkopf Kokille Indiziert+AV-Messstellen", "Rohteil Zylinderkopf Kokille Endoskopie", _
"Rohteil Zylinderkopf Kokille Vollvermessen", "Rohteil Zylinderkopf Kokille", _
"Rohteil Zylinderkopf Kokille", "Rohteil Zylinderkopf Kokille", "Rohteil Zylinderkopf Kokille", _
"Rohteil Zylinderkopf Kokille", "Rohteil Zylinderkopf Kokille")
Zwischenspeicher = ""
'Checkoboxen zählen
For Each cntrl In Me.Controls
If TypeName(cntrl) = "CheckBox" Then
If cntrl Then CheckBoxAnzahlIP = CheckBoxAnzahlIP + 1
End If
Next
'Ausgabe Spalte Benennung
zeile = Cells(Rows.Count, 1).End(xlUp).Row + 1
For i = 1 To CheckBoxAnzahlIP
Cells(zeile, 2) = TextBox1.Text
Cells(zeile, 6) = TextBox2.Text
Cells(zeile, 1) = "x"
'neu
If Me.Controls("Checkbox" & i).Value = True Then Zwischenspeicher = werte(i - 1)
'oder bei Userform1 so
' UserForm1.Controls("Checkbox" & i).Value = True Then Zwischenspeicher = werte(i - 1)
Cells(zeile, 9) = Zwischenspeicher
zeile = zeile + 1
Zwischenspeicher = ""
Next i
End Sub
|