Re: Bräuchte Hilfe bei UserForm Buttons
27.09.2002 23:45:34
Heinz
Der folgende Code ist total semmel aber funktioniert. man muss nur aufpassen dass die options in jeweils eigenen frames (rahmen) sind. klar gibts besseren code mit collections für die options um schleifen verwenden zu können aber was solls, kann mir e nicht vorstellen wozus dienen sollgruß, heinz
Private Sub CommandButton1_Click()
Dim i As Integer
Dim j As Integer
i = 0
j = 0
If OptionButton1.Value = True Then i = i + 1
If OptionButton2.Value = True Then i = i + 1
If OptionButton3.Value = True Then i = i + 1
If OptionButton4.Value = True Then i = i + 1
If OptionButton5.Value = True Then i = i + 1
If OptionButton6.Value = True Then i = i + 1
If OptionButton7.Value = True Then i = i + 1
If OptionButton8.Value = True Then i = i + 1
If OptionButton9.Value = True Then i = i + 1
If i > 3 Then
MsgBox "Zuviele Optionen gewählt"
OptionButton1.Value = False
OptionButton2.Value = False
OptionButton3.Value = False
OptionButton4.Value = False
OptionButton5.Value = False
OptionButton6.Value = False
OptionButton7.Value = False
OptionButton8.Value = False
OptionButton9.Value = False
Exit Sub
End If
If OptionButton1.Value = True Then
j = j + 1
Sheets("Frei").Cells(1, j) = 1
End If
If OptionButton2.Value = True Then
j = j + 1
Sheets("Frei").Cells(1, j) = 2
End If
If OptionButton3.Value = True Then
j = j + 1
Sheets("Frei").Cells(1, j) = 3
End If
If OptionButton4.Value = True Then
j = j + 1
Sheets("Frei").Cells(1, j) = 4
End If
If OptionButton5.Value = True Then
j = j + 1
Sheets("Frei").Cells(1, j) = 5
End If
If OptionButton6.Value = True Then
j = j + 1
Sheets("Frei").Cells(1, j) = 6
End If
If OptionButton7.Value = True Then
j = j + 1
Sheets("Frei").Cells(1, j) = 7
End If
If OptionButton8.Value = True Then
j = j + 1
Sheets("Frei").Cells(1, j) = 8
End If
If OptionButton9.Value = True Then
j = j + 1
Sheets("Frei").Cells(1, j) = 9
End If
End Sub
Private Sub CommandButton2_Click()
OptionButton1.Value = False
OptionButton2.Value = False
OptionButton3.Value = False
OptionButton4.Value = False
OptionButton5.Value = False
OptionButton6.Value = False
OptionButton7.Value = False
OptionButton8.Value = False
OptionButton9.Value = False
Sheets("Frei").Rows(1).ClearContents
End Sub