Ich habe ein ganz komisches Problem. Ich habe ein UserForm, bei dem man eine Zahl zwischen 0 und 3 anklicken kann (Radio-Buttons). Im zweiten Teil des UserForms kann man zwischen Gold, Silver und Bronze wählen (Option-Buttons).
Nun möchte ich kontrollieren, dass wenn man das Kästchen "1" angeklickt hat, dass man dann nur eine Farbe (also entweder Gold oder Silver oder Bronze) anklicken kann. Dementsprechend für 2 und bei 3 muss man halt alle!
Dazu habe ich folgende Codes geschrieben:
Private Sub SimpleGold_Click()
If Simple1.Value = True Then
If SimpleSilver.Value = True Then
myClicksSimple = myClicksSimple + 1
End If
If SimpleBronze.Value = True Then
myClicksSimple = myClicksSimple + 1
End If
If myClicksSimple > 0 Then
MsgBox "Wrong combination - you can only select one value for SL Category!"
SimpleGold.Value = False
SimpleSilver.Value = False
SimpleBronze.Value = False
Exit Sub
End If
End If
If Simple2.Value = True Then
If SimpleSilver.Value = True Then
myClicksSimple = myClicksSimple + 1
End If
If SimpleBronze.Value = True Then
myClicksSimple = myClicksSimple + 1
End If
If myClicksSimple > 1 Then
MsgBox "Wrong combination - you can only select one value for SL Category!"
SimpleGold.Value = False
SimpleSilver.Value = False
SimpleBronze.Value = False
Exit Sub
End If
End If
End Sub
Private Sub SimpleSilver_Click()
If Simple1.Value = True Then
If SimpleGold.Value = True Then
myClicksSimple = myClicksSimple + 1
End If
If SimpleBronze.Value = True Then
myClicksSimple = myClicksSimple + 1
End If
If myClicksSimple > 0 Then
MsgBox "Wrong combination - you can only select one value for SL Category!"
SimpleSilver.Value = False
SimpleBronze.Value = False
SimpleGold.Value = False
Exit Sub
End If
End If
If Simple2.Value = True Then
If SimpleGold.Value = True Then
myClicksSimple = myClicksSimple + 1
End If
If SimpleBronze.Value = True Then
myClicksSimple = myClicksSimple + 1
End If
If myClicksSimple > 1 Then
MsgBox "Wrong combination - you can only select one value for SL Category!"
SimpleGold.Value = False
SimpleSilver.Value = False
SimpleBronze.Value = False
Exit Sub
End If
End If
End Sub
Private Sub SimpleBronze_Click()
If Simple1.Value = True Then
If SimpleGold.Value = True Then
myClicksSimple = myClicksSimple + 1
End If
If SimpleSilver.Value = True Then
myClicksSimple = myClicksSimple + 1
End If
If myClicksSimple > 0 Then
MsgBox "Wrong combination - you can only select one value for SL Category!"
SimpleGold.Value = False
SimpleSilver.Value = False
SimpleBronze.Value = False
Exit Sub
End If
End If
If Simple2.Value = True Then
If SimpleGold.Value = True Then
myClicksSimple = myClicksSimple + 1
End If
If SimpleSilver.Value = True Then
myClicksSimple = myClicksSimple + 1
End If
If myClicksSimple > 1 Then
MsgBox "Wrong combination - you can only select one value for SL Category!"
SimpleGold.Value = False
SimpleSilver.Value = False
SimpleBronze.Value = False
Exit Sub
End If
End If
End Sub
Wenn ich jetzt z.B. die 1 gewählt habe und dann zuerst Bronze anklicke, passiert ja noch nichts, weil ich erst ein Kästchen angeklickt habe. Wenn ich jetzt aber zusätzlich noch Silver anklicke, dann springt er ja in folgendes Sub:Private Sub SimpleSilver_Click()
Das durchläuft er genau bis
If Simple1.Value = True Then
If SimpleGold.Value = True Then
myClicksSimple = myClicksSimple + 1
End If
If SimpleBronze.Value = True Then
myClicksSimple = myClicksSimple + 1
End If
If myClicksSimple > 0 Then
MsgBox "Wrong combination - you can only select one value for SL Category!"
SimpleSilver.Value = False
SimpleBronze.Value = False 'HIER!!!!!!
SimpleGold.Value = False
Exit Sub
End If
Dort wo HIER!!! steht, springt er sofort ins Private Sub SimpleBronze_Click() und macht nicht einfach in "seinem" eigenen Code weiter.Wieso ist das so? Wie kann ich diesen Fehler beheben?
Oder gibt es noch eine andere Möglichkeit, zu erreichen, was ich möchte?
Wäre echt froh um Hilfe, weil ich hab nicht mal eine Ahnung, wie ich das googeln konnte -.-
Ganz liebe Grüsse
Ximena