gibt es ne elegantere Variante für meinen Code hier? Soweit klappt das gut allerdings doch recht unübersichtlich das ganze. :D
Im Prinzip soll er den Code für 8 Textboxen ausführen also bei 8 Verschiednen Exits habe es mit ner Do Schleife probiert allerdings hat er natürlich nur wenn ich aus Textbox 1 raus bin die Werte übernommen.
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim i As Integer
i = 1
If Controls("TextBox" & i).Value > 8000 Then
TextBox16.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 7000 _
Then TextBox15.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 6000 _
Then TextBox14.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 5000 _
Then TextBox13.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 4000 _
Then TextBox12.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 3000 _
Then TextBox11.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 2000 _
Then TextBox10.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 1000 _
Then TextBox9.Value = Controls("TextBox" & i).Value
End If
End Sub
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim i As Integer
i = 2
If Controls("TextBox" & i).Value > 8000 Then
TextBox16.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 7000 _
Then TextBox15.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 6000 _
Then TextBox14.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 5000 _
Then TextBox13.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 4000 _
Then TextBox12.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 3000 _
Then TextBox11.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 2000 _
Then TextBox10.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 1000 _
Then TextBox9.Value = Controls("TextBox" & i).Value
End If
End Sub
Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim i As Integer
i = 3
If Controls("TextBox" & i).Value > 8000 Then
TextBox16.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 7000 _
Then TextBox15.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 6000 _
Then TextBox14.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 5000 _
Then TextBox13.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 4000 _
Then TextBox12.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 3000 _
Then TextBox11.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 2000 _
Then TextBox10.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 1000 _
Then TextBox9.Value = Controls("TextBox" & i).Value
End If
End Sub
Private Sub TextBox4_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim i As Integer
i = 4
If Controls("TextBox" & i).Value > 8000 Then
TextBox16.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 7000 _
Then TextBox15.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 6000 _
Then TextBox14.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 5000 _
Then TextBox13.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 4000 _
Then TextBox12.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 3000 _
Then TextBox11.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 2000 _
Then TextBox10.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 1000 _
Then TextBox9.Value = Controls("TextBox" & i).Value
End If
End Sub
Private Sub TextBox5_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim i As Integer
i = 5
If Controls("TextBox" & i).Value > 8000 Then
TextBox16.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 7000 _
Then TextBox15.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 6000 _
Then TextBox14.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 5000 _
Then TextBox13.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 4000 _
Then TextBox12.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 3000 _
Then TextBox11.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 2000 _
Then TextBox10.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 1000 _
Then TextBox9.Value = Controls("TextBox" & i).Value
End If
End Sub
Private Sub TextBox6_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim i As Integer
i = 6
If Controls("TextBox" & i).Value > 8000 Then
TextBox16.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 7000 _
Then TextBox15.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 6000 _
Then TextBox14.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 5000 _
Then TextBox13.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 4000 _
Then TextBox12.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 3000 _
Then TextBox11.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 2000 _
Then TextBox10.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 1000 _
Then TextBox9.Value = Controls("TextBox" & i).Value
End If
End Sub
Private Sub TextBox7_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim i As Integer
i = 7
If Controls("TextBox" & i).Value > 8000 Then
TextBox16.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 7000 _
Then TextBox15.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 6000 _
Then TextBox14.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 5000 _
Then TextBox13.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 4000 _
Then TextBox12.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 3000 _
Then TextBox11.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 2000 _
Then TextBox10.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 1000 _
Then TextBox9.Value = Controls("TextBox" & i).Value
End If
End Sub
Private Sub TextBox8_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim i As Integer
i = 8
If Controls("TextBox" & i).Value > 8000 Then
TextBox16.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 7000 _
Then TextBox15.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 6000 _
Then TextBox14.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 5000 _
Then TextBox13.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 4000 _
Then TextBox12.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 3000 _
Then TextBox11.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 2000 _
Then TextBox10.Value = Controls("TextBox" & i).Value
ElseIf Controls("TextBox" & i).Value 1000 _
Then TextBox9.Value = Controls("TextBox" & i).Value
End If
End Sub