Ein IF-Befehl reagiert immer auf True oder False, deswegen brauchst du nicht zu schreiben:
If ChkBoxXY = True Then ...
sondern es reicht:
If ChkBoxXY Then ... (denn das ist gleichbedeutend mit If True Then bzw If False Then).
Wenn du schon im Code der Userform bist, reicht "Me" statt "UserformXYZ".
Probiere das aus:
Public Sub OK_click()
Dim i As Integer
Do While Worksheets( "Archiv" ).Cells(4 + i, 2).Value <> Empty
i = i + 1
Loop
Worksheets( "Archiv" ).Cells(4 + i, 1) = i + 1
Worksheets( "Archiv" ).Cells(4 + i, 2).Value = Person_anlegen.TextBox1.Value
Worksheets( "Archiv" ).Cells(4 + i, 3).Value = Person_anlegen.TextBox2.Value
Worksheets( "Archiv" ).Cells(4 + i, 4).Value = Person_anlegen.TextBox3.Value
Worksheets( "Archiv" ).Cells(4 + i, 5).Value = Person_anlegen.TextBox4.Value
If NOT(Chkbx_BF OR Chkbx_WF OR Chkbx_WG OR Chkbx_JET) Then
MsgBox "Qualifikation ankreuzen!" , vbOKOnly + vbInformation, "Warnung"
Exit Sub
End If
If Chkbx_BF Then
Worksheets( "Archiv" ).Cells(4 + i, 6) = "x"
End If
If Chkbx_WF Then
Worksheets( "Archiv" ).Cells(4 + i, 7) = "x"
End If
If Chkbx_WG Then
Worksheets( "Archiv" ).Cells(4 + i, 8) = "x"
End If
If Chkbx_JET Then
Worksheets( "Archiv" ).Cells(4 + i, 9) = "x"
End If
Unload Me
End Sub
Dein Code macht aber immer nur "x", wenn Checkbox angekreuzt ist, aber er entfernt das "x" nicht, wenn nicht angekreuzt.
Dafür müsstest du bei allen Checkboxen den Code z.B. so ändern:
If Chkbx_BF Then
Worksheets( "Archiv" ).Cells(4 + i, 6) = "x"
Else
Wor ksheets( "Archiv" ).Cells(4 + i, 6) = ""
End If
|